Earth’s magnetic field protects and makes our planet habitable by stopping harmful high-energy particles from space, including from the Sun. The source of this magnetic field is the core at the center of our planet.
The Earth’s core is cooling down very slowly over time. One day, when the core has completely cooled and become solid, it will have a huge impact on the whole planet. Scientists think that when that happens, Earth might be a bit like Mars, with a very thin atmosphere and no more volcanoes or earthquakes. Then it would be very difficult for life to survive – but that won’t be a problem for several billions of years
Whether or not a planet has a magnetic field goes a long way towards determining whether or not it is habitable. Whereas Earth has a strong magnetosphere that protects life from harmful radiation and keeps solar wind from stripping away its atmosphere, planet’s like Mars no longer do. Hence why it went from being a world with a thicker atmosphere and liquid water on its surface to the cold, desiccated place it is today.