Not all objects in space have an atmosphere. Its atmosphere is made up mostly of nitrogen and oxygen. Dust particles float inside the atmosphere. So do clouds and microbes. The clouds are water droplets that form rain.
Earth has a magnetic field all around it.
The magnetic field begins inside Earth's core and goes out way beyond the atmosphere. A magnetic field acts like a magnet. Earth's atmosphere and the magnetic field above it block most of the deadly rays from the sun and other stars. Sometimes chunks of rock in space, called meteorites, attracted by Earth's gravity, enter our atmosphere. The atmosphere burns up most meteorites before they can hit Earth.