why does a magnetic bar hung from a string always comes to rest in north south direction
A freely suspended magnet will also point towards south. The south pole of a magnet bar points towards north because the magnetic field around the earth happens to have its north pole towards north. South and north attract eachother. The magnetic north pole that is. That is why a compass work as it does. The small needle in it, is a magnet. It will point towards the north and south as the magnetic fields align with each other to rest at their equilibruim - the point where no magnetic forces will further change the direction of the compass needle.
It’s important, for a compass to work correctly, that you do not carry magnets or magnetic materials with you that will affect the needle in the compass to point in the wrong direction.