The Earth’s magnetic field is created by the rotation of the Earth and Earth's core. It shields the Earth against harmful particles in space. The field is unstable and has changed often in the history of the Earth. As the Earth spins the two parts of the core move at different speeds and this is thought to generate the magnetic field around the Earth as though it had a large bar magnet inside it.