Answer:
Magnetic material such as iron and nickel are present in core of the earth. The domains of the magnetic material arranged in uni-direction creating the enormous magnetic field of the Earth.
The magnetosphere surrounds the Earth and protects from the incoming high speed charged particles from the sun by deflecting them further into space.