Differences in temperature, pressure and composition within the outer core cause convection currents in the molten metal as cool, dense matter sinks whilst warm, less dense matter rises. The Coriolis force, resulting from the Earth’s spin, also causes swirling whirlpools.
This flow of liquid iron generates electric currents, which in turn produce magnetic fields. Charged metals passing through these fields go on to create electric currents of their own, and so the cycle continues. This self-sustaining loop is known as the geodynamo.