Earth has a magnetic field because the core of the earth is made of ~~liquid~~ iron, with a solid iron inner core surrounded by a liquid iron outer core. Iron is magnetic, so much so that we call things that are attracted to magnets “ferromagnetic”, from the Latin word “ferrum” which means iron. The magnetic field of earth is important because without it life would not be possible. The Earth is constantly being bombarded with powerful radiation and charged particles from the sun and from outerspace, all of which are very deadly to living organisms. But, these particles get trapped in Earth’s magnetic field, where the are harmlessly moved towards the poles. Instead of killing you, they put on the brilliant light shows called the auroras: Aurora Borealis & Aurora Australis
Bonus edit: magnetic fields are thought to be so vital to the development of life itself that many scientist consider a metal core to be a necessary component of any planet potentially fostering extraterrestrial life.
Beyond having a magnetic core from the iron inside our planet when it formed, the Earth was also struck by another Planet sided object, around the size of Mars.
This caused two things to happen, 1) the Earths iron increased in size dramatically and 2) the moon was formed.
The magnetic core mostly blocks the solar radiation as it’s most important function protecting the atmosphere.
Humans are hairless monkeys with fragile DNA*
Edit* so does every other living thing. Just in case I had to point that out.
The Sun is a magnanimous sphere of infernal plasma whose radiation whips out at us constantly
Thank mother earth we happen to have a swirling molten core of metal which generates the magnetic shield.
The explanation a 5yo could understand:
Metal in motion makes a magnetic field
The same way that a magnetic field will make a metal undergo motion
Latest Answers