The Earth and most other planets in the Solar System, including the Sun and stars, all generate magnetic fields through the motion of electrically conducting fluids.

The Earth's magnetic field is like a giant invisible bubble that starts from the Earth's inside and extends into space. It is generated by electric currents caused by the motion of molten metals.

The Earth's core is made up of molten iron and nickel which keep moving constantly due to heat generated by the solid inner core, the rotation of the Earth, and the convection currents in the core.

These factors create a dynamo effect, which generates and sustains the Earth's magnetic field. According to Paleomagnetic studies, the Earth's magnetic field has been there for over 3,450 million years.

The Earth's magnetic field is crucial to sustaining any form of life on our planet, as it protects us from the harmful effects of solar wind and cosmic radiation.

The Earth's magnetic field deflects most of the harmful solar wind, which can otherwise strip the ozone layer. They also protect us from ultraviolet radiation that harms life on Earth.

This field is strongest at the poles and weakest at the equator. It It is not constant and changes over time, and it can even flip, meaning the north and south magnetic poles can switch places.