From geological records in rocks and minerals we know that the magnetic field of Earth changed its polarity multiple times in the history. See Geomagnetic reversal. Was a similar process of a ...
Earth's core is a giant liquid iron ball actually. If I know well, the magnetic field of our planet (that protects the surface from some particles comes from the Sun) can exist because as Earth ...