The outer core is in many ways even less well understood, though everyone is in agreement that it is fluid and that it is the seat of magnetism. The theory was put forward by E. C. Bullard of Cambridge University in 1949 that this fluid part of the Earth's core revolves in a way that makes it, in effect, an electrical motor, creating the Earth's magnetic field. The assumption is that the convecting fluids in the Earth act somehow like the currents in wires. Exactly what happens isn't known, but it is felt pretty certain that it is connected with the core spinning and with its being liquid. Bodies that don't have a liquid core—the Moon and Mars, for instance—don't have magnetism.
We know that Earth's magnetic field changes in power from time to time: during the age of the dinosaurs, it was up to three times as strong as now. We also know that it reverses itself every 500,000 years or so on average, though that average hides a huge degree of unpredictability. The last reversal was about 750,000 years ago. Sometimes it stays put for millions of years—37 million years appears to be the longest stretch—and at other times it has reversed after as little as 20,000 years. Altogether in the last 100 million years it has reversed itself about two hundred times, and we don't have any real idea why. It has been called "the greatest unanswered question in the geological sciences."