But how does a compass work? The answer is: by magnetic force.
When you place a magnet amidst metal filings, you can see how these filings are pulled to the magnet. And when you take a closer look, you can see that the filings arrange themselves in specific directions at the magnet. This way, you can see where the field lines of the magnet run. The horseshoe magnet has a north pole and a south pole like the Earth. The direction of the cuttings tells you where the field lines along these poles are.
Just like the metal filings, the pointer of a compass is also pulled towards a magnet. If you move the magnet around the compass, you can see how the pointer follows the magnet.