Many scientists think that a magnetic field of a planet serves as a shield for the atmosphere, deflecting solar wind particles around the planet in a bit of a force field-type effect having to do with electric charge of those particles.