Earth is like a giant magnet in several ways. Not only does it have a magnetic north and south pole that act similarly to the poles on bar magnets, but the planet is surrounded by a strong magnetic field, which is electrically charged and able to interact with magnetized matter.
The Earth's magnetism is a direct result of a process called the dynamo effect. In the dynamo effect, the Earth's solid core transfers heat through the molten outer core and up to the surface of the planet via convection, according to Why Do. This causes the liquid part of the core to move, which results in an electrical current. The movement of the Earth as it orbits and spins keeps the liquid core, which is made up of primarily iron and nickel, in constant motion as well. This is why the magnetic force never falters or gets weaker.
Interestingly, most planets and moons are not as magnetic as Earth, which makes the planet unique and interesting in many ways. In fact, most heavenly bodies have very little or no magnetic properties. This is just one of the ways that the planet Earth stands out among the planets, moons and stars in the solar system.