Earth's Earliest Atmosphere and Climate

The composition of the atmosphere of the Earth is a result of the accumulation of matter in the premordial solar system as the Sun was forming. The material in the galaxy was attracted to the sun by gravity. The material (elements) coalesced to form planets.
The heavy elements of the Earth were more dense and condensed to the center while the lighter (less dense) material rose to the surface.
Earth's special atmosphere arises from the special location the Earth is in the solar system. If the Earth was too close to the sun water would not exist in the liquid state; too far away and water would not exist in the liquid state.
However, the Earth's atmosphere took millions of years to evolve to a condition that was suitable for life to exist.
One of the most important changes that occured to the atmosphere was the development of excess oxygen. In the earliest atmosphere any free oxygen would have been captured by metalic minerals in the sediments and rocks to form oxidized rocks and minerals (the rocks would have "rusted" ). Evidence that this was happening in the earliest atmosphere can be found in the Precambrian Redbeds

Precambrian Red beds

The evolution of Earth's oxygen atmosphere
It was not until around 4 billion years ago that the earliest oxygen producing (photosynthesizing) organism occurred. With the presence of these organisms there was excess oxygen being formed. Eventually, oxygen built up in the atmosphere but this took millions of years.