Earth's magnetic field is important for sustaining life as it deflects radiation. In addition, it prevents solar winds from the sun blowing directly into Earth's atmosphere.
Harmful particles from space constantly head towards Earth. However, because of the magnetic field, most of them are deflected. The magnetosphere is able to achieve this because its electrical charge causes incoming electrically charged particles to bounce off it. There are some areas of the world where this does not happen, though, such as the two poles. When particles do enter around the North Pole, they cause the Aurora Borealis.
There are other forms of high-energy radiation that could come into contact with the Earth, but they are kept away by the radiation belts, which are also known as the Van Allen radiation belts. Because of their presence, radiation moves around the Earth rather than towards it.
Solar wind consistently blows towards the Earth at a rate of around 248 miles an hour. The Earth's magnetosphere produces something called a bow shock, which stops the solar winds from entering the atmosphere. How strong the winds are depends on the intensity of the sun. However, they do contain harmful ionizing gases. It is the sun's solar wind that is responsible for the harmful particles that head towards the Earth and cause Aurora Borealis to appear.