Scientists believe that the Earth's magnetic field is generated by a geodynamo process occurring in the outer core, which is composed of liquid iron and nickel. The correct explanation is:
The liquid iron and nickel outer core's motion in relation to the metallic solid inner core becomes a geodynamo.
This geodynamo mechanism involves the flow of the electrically conductive liquid in the outer core, driven by convection currents caused by heat from the inner core and the cooling of the Earth. The motion of this conducting fluid generates electric currents, which in turn produce magnetic fields. The combination of these magnetic fields results in the large-scale magnetic field that surrounds the Earth.