The Earth is a giant magnet. Its hot liquid centre core contains iron, and as it moves, it creates an electric current that causes a magnetic field around the Earth. The Earth has a north and south magnetic pole which is opposite to the geographic north and south.

a magnetic compasson the surface of the Earth will point along the magnetic field lines, towards the north magnetic pole.compass needle behaves like a tiny magnet and as opposite poles attract south of compass needle(i.e. geographic south) points to the earth's magnetic north and vice versa.

Because it is affected by the earth's gravity.