Earth itself behaves like a huge bar magnet with its magnetic poles near the geographical north and south poles. The south pole of this bar magnet is near the geographical north pole and north pole at the geographical south pole. Therefore, when a magnet is suspended freely, the magnetic poles of the earth attract the opposite poles of the magnet and the magnet comes to rest in the north-south direction.