It helps protect us from the many different kinds of particles that travel from the Sun to the Earth on the solar wind. Solar flares are tremendous explosions on the surface of the Sun. Energetic particles from flares can pose a hazard to astronauts and spacecraft outside the protection of Earth's magnetosphere. Solar flares are not the same as coronal mass ejections, although they often happen together. The solar wind blows all the time, although it is most intense during the days after a coronal mass ejection.
Sunspots are cools areas with powerful magnetic fields.
These magnetic fields store the energy for powerful explosions like solar flares and coronal mass ejections.