Activity
Take two bar magnet, one magnet bar attach to retort stand with the help of string. When magnet on retort comes to rest position then another bar magnet and hold in your hand. Bringing north pole near to a south pole of magnet which is suspended on retort stand. Observe both the magnet bar, both poles are attracted to each other. Now north pole brought near to North pole, then what will be your observation? Both poles are repel to each other.
From this activity its clear that when two like poles comes together they repel to each other. When unlike pole comes together they attract to each other.