How Can a Compass Find North Without Electricity?
A compass needle is a small permanent magnet balanced so that it can rotate freely.
Earth is surrounded by a magnetic field generated mainly by moving, electrically conducting liquid iron in its outer core. The compass aligns itself with that field. One end points approximately toward the geographic North Pole, although it is technically attracted toward a magnetic pole of the opposite type.
Magnetic north and geographic north are not identical. The difference between them, called magnetic declination, varies by location and changes over time as movement inside Earth shifts the magnetic field. Navigators using a map may need to correct for it. The magnetic poles themselves wander rather than remaining at fixed points.
A compass can also tilt because Earth’s field enters the planet at an angle. Many precision needles are balanced for the region in which they will be used. One designed for the Northern Hemisphere may drag against its casing when carried far south. Nearby iron, electrical equipment, magnets, and parts of a vehicle can disturb the reading. Near the magnetic poles, an ordinary horizontal compass also becomes less reliable because much of the field points steeply downward.
The compass works because the entire planet behaves somewhat like an enormous, changing magnet, and the needle is free to follow its field.
Source: Earth’s Magnetic Field, British Geological Survey - Geomagnetism, United States Geological Survey

Red Weaver ant (Oecophylla smaragdina)
Source: Muhammad Mahdi Karim