Earth's Magnetic Field
Moving electric charges generate magnetic fields. For example, you can create a magnetic field by wrapping wire around an iron bar and then applying current to the wire (an electromagnet). In a similar way, Earth generates a planetary geomagnetic field, one that protects our atmosphere from solar wind, allows for navigation, and can be used to date geologic events. The Earth's magnetic field is thought to be created by electrical interactions between the Earth's solid inner core and liquid outer core, movement of iron-rich fluid in the outer core, and the planet's rotation. Collectively, the factors that lead to the creation of the Earth's magnetic field are called the Earth's geodynamo.
Remnant Magnetism
As molten rock cools, crystallizing magnetic minerals (e.g., magnetite) align themselves to the ambient magnetic field of the Earth. Therefore, studying the magnetic signatures in rocks provides information about the strength and direction of the Earth's magnetic field when that rock was formed. By studying the paleomagnetism of rocks with a wide variety of ages, we can estimate how the geomagnetic field of the Earth (and it's geodynamo) has behaved throughout its history. For example, based on magnetism of ancient rocks, scientists believe that the Earth's magnetic field has been active for approximately 3.5 billion years.
Why ocean crust?
It is easier to decipher the history of the Earth's magnetic field from oceanic crust than from continental crust. Oceanic crust is mainly composed of basalt, which contains minerals susceptible to magnetization. Oceanic crust also has a relatively simple life cycle, whereas continental rocks may be subjected to a variety of processes that can make them difficult to age-date and cause re- or de-magnetization. By comparison, measuring the ages and magnetic properties of ocean crust is relatively straight-forward. However, it is still important to study the paleomagnetism of continental crust, because the marine magnetic record relatively young by comparison.
Marine Magnetic Anomalies
Magnetic measurements of the seafloor show that the geomagnetic field has changed through time. Ocean crust is generated at mid-ocean ridges, underwater spines of volcanic mountains that run through every ocean. As new crust cools, it moves away from the ridge, eventually being destroyed under continental crust in subduction zones. This regular progression means that we have a relatively complete record of oceanic crust that was formed between the present day and the Jurassic period of the Mesozoic era, ~180 million years ago. The magnetic properties of these seafloor materials correlate closely with the age of the rocks and are called marine magnetic anomalies. The anomalies show that the intensity and polarity of the Earth's magnetic field has changed throughout geologic history, and these changes reflect the dynamic history of the Earth's geodynamo.
More Information
NASA: Magnetic Pole Reversal Happens All The (Geologic) Time