The reason for the polarity reversal seems to be in the way that magnetic dynamos evolve in time. We see this process taking place in the sun every 22 years, so this makes it easier to study the process than for the earth's field. According to the Parker Magnetic Dynamo Theory developed in the 1960's, you need several ingredients including a conductive region that is spinning, and a convecting region. Lines of magnetic flux become wrapped around the rotating core and become buoyant. The float up into the convecting layer and become cyclonically twisted until they pop through the surface as 'sunspots'. The sunspot fields are born with polarities such that the leading spot has the opposite polarity of the hemisphere it is in. If the large-scale field is dipolar, then the migration of these sunspot fields across the solar surface is supposed to neutralize some of the original dipolar field. As the sunspot cycle reaches its maximum, most of the spots are near the equatorial region and produce a strong toroidal solar field. As the cycle weakens thereafter, the toroidal field weakens and what remains is a large scale dipolar field with an opposite polarity to what it had at the start of the sunspot cycle. After two sunspot cycles...22 years or so...the original polarity is reestablished.
For the Earth, the theory may still apply except that the quantities that define the electrical conductivity, matter density and resistivity, and rotation rates are different. A back of the envelope calculation lets you use this theory to recover the 22 year solar cycle, and the 250,000 year terrestrial cycle, from the same equation. Presumably inside the Earth, the iron-nickel core is highly conducting, and is surrounded by a convecting mantle in which magnetic flux can get trapped and cyclonically convected deep inside the Earth. We do not see the 'sunspots' inside the Earth like the surface markings on the sun because the physics is different. We may eventually be able to map out the magnetic field distribution in the core region and discover such features.
All answers are provided by Dr. Sten Odenwald (Raytheon STX) for the
NASA IMAGE/POETRY project.