|MadSci Network: Earth Sciences|
That's a wonderful question, and I regret to say we don't have a perfect answer yet (perhaps it's a good thing: life would be boring if we knew all the answers already!). Here's the best guess right now:
The Earth's magnetic field looks like a bar-magnet's field. Unfortunately, while they look the same, they are totally different in origin. Our magnetic field is much more like an electromagnet than a bar magnet.
In both an electromagnet and the Earth, the magetic field is created by moving electrical currents. In the electromagnet, the currents are the currents you usually run through wires in every electrical appliance in your home or school. But in the Earth's outer core (the part that is a liquid) the electrical currents are actually iron/metal liquid moving about. The way the currents move creates the characteristics of the magnetic field.
When you think about it, this means there isn't any really good reason why the Earth's magnetic field should be constant. It's easy to imagine that the fluid currents in the Earth might change in time. It's especially easy when you understand that electrical currents are also forced to change direction by magnetic fields, even ones they themselves create. So a small irregularity in the motion in the Earth's core could easily feed back on itself, build up, and eventually move the Earth's field, causing it to reverse or even disappear.
It's hard to suggest a good reference on this topic; all the ones I know are either too brief or much too technical (if you find a good book on magnetic fields of planets that isn't written for professional scientists, let me know...). But I'd start by recommending William K. Hartmann's textbook "Moons and Planets". He spends a few pages talking about the basics of planetary mangnetic fields, doing a pretty good job of it.
Hope that that helps!
Try the links in the MadSci Library for more information on Earth Sciences.