There are a number of hypotheses explaining the origin of the Earth's magnetic field. Recently, a theory has been developed that connects the occurrence of the Earth's magnetic field with the flow of currents in the liquid metal core. It is calculated that the zone in which the "magnetic dynamo" mechanism operates is at a distance of 0.25 ... 0.3 of the Earth's radius.
It should be noted that the hypotheses explaining the mechanism of the formation of the magnetic field of planets are rather contradictory and have not been experimentally confirmed so far.
As for the Earth's magnetic field, it has been reliably established that it is sensitive to solar activity. At the same time, a solar flare cannot have a noticeable effect on the Earth's core. On the other hand, if we associate the occurrence of the magnetic field of the planets with the current sheets in the liquid core, then we can conclude that the planets of the solar system having the same direction of rotation should have the same direction of magnetic fields. So Jupiter, rotating around its axis in the same direction as the Earth, has a magnetic field directed opposite to that of the Earth.