Scientists believe that the earth's magnetism is created by slow movements in the liquid outer core, caused by the rotation of the earth. The generation of the earth's magnetic field is a continuous, but variable, process that causes change in not only the intensity of the magnetic field, but also causes the Magnetic North Pole to move as well as the reversal of the earth's entire magnetic field.
Lava, which hardens into rock, contains grains of iron oxides that point toward the magnetic pole as the rock solidifies. Thus, these grains are permanent records of the location of the earth's magnetic field. As new crust is created on the ocean floor (such as at the Mid-Atlantic ridge), the new crust solidifies, with its iron oxide acting like miniature compass needles. Scientists have matched the magnetic bands on either side of the Mid-Atlantic ridge out to the edges of the ocean. To determine the distance between the Americas and Europe and Africa at any point since Pangea, one need only to "roll back" the oceanic crust to the appropriate matching magnetic bands on either side of the ridge. Magnetic reversals helped to prove the theory of plate tectonics and continental drift.
The earth's magnetic field has reversed approximately 170 times over the last 100 million years. The intensity of the magnetic field has been decreasing over time since it has been measured and some scientists expect that at the current rate of decline, there may be another magnetic reversal in approximately 2000 years. That should be enough time to replace all of our compasses.