Earth is a big magnet.
Which is kind of amazing. The magnetic field is produced by some remarkable result of the convection of molten hot iron alloys in the core of the Earth. Kind of hard to really get your head round if you’re sitting calmly at your desk or walking on a nice stable surface. Periodically, the poles switch round it seems but at the moment the magnetic South pole is actually near the point we’d normally call the geographical North pole. They’re pretty close, but the geographic axis doesn’t exactly coincide along the geographic axis of rotation of Earth. And the lines of force go from magnetic North to magnetic South so your compass needle is actually pointing towards magnetic South. Remember iron filings and bar magnets from physics class?