geomagnetism

Why does the Earth, as well as other planets and stars, have a magnetic field?
Where do the magnetic fields of planets and stars come from?
It's a good question with a fascinating answer.