Where do you think the magnetic field comes from? ;_;
The earth's outer core layer. A layer of molten rock and metal that's constantly moving due to convection currents, which is what creates the magnetic field and gives us the north and south poles.