How does the Earth's core generate a magnetic field?
Briefly, as the result of radioactive heating and chemical differentiation, the Earth's outer core is in a state of turbulent convection. This sets up a process that is a bit like a naturally occurring electrical generator, where the convective kinetic energy is converted to electrical and magnetic energy. Basically, the motion of the electrically conducting iron in the presence of the Earth's magnetic field induces electric currents. Those electric currents generate their own magnetic field, and as the result of this internal feedback, the process is self-sustaining so long as there is an energy source sufficient to maintain convection.