Over the course of the over four and a half billion years since the earth began forming, it has gone through many changes. One of the most important developments was the atmosphere that supports life on this planet. There are many theories as to how it developed and while there is some scientific evidence to suggest how it might have happened, no one definitively knows the exact steps in its formation. The atmosphere likely underwent many distinct stages or changes during its evolution in order to become what it is today.
The earliest atmosphere that formed on this planet was likely devoid of any nitrogen or oxygen that it is primarily comprised of today. The main gases present may have been hydrogen and helium which were leftover from the formation of the sun. These gases may have left the weak atmosphere and diffused into space as a result of solar winds, low gravity, and a lack of magnetic field. Once the planet was stabilized, the heavier gases remained.
With the loss of hydrogen and helium, the atmosphere changed as volcanic activity produced a variety of gases that dominated the new atmosphere (volcanic out gassing). The gases could have been the same or similar to the ones which are still produced by modern volcanic activity and could have included: carbon dioxide, sulfur, chlorine, nitrogen, methane, ammonia, sulfur dioxide, water vapor and possible hydrogen bromide, hydrogen fluoride, and hydrogen sulfide.
Addition of water
The large amounts of greenhouse gases in the atmosphere would have kept the planet relatively warm in the short-term but eventually the planet began cooling down. As the Earth cooled and temperatures dropped, the atmosphere would have also changed over the course of over a billion years and lost many of the volcanic gases to become comprised of carbon dioxide, water, and nitrogen. The cooling would have also caused the water vapor to liquefy and begin collecting to form an ocean or oceans.
While not everything is known about when or how events occurred, it is approximated that oxygen began increasing in concentration in the atmosphere about two and half billion years ago. Before that time, cyanobacteria likely produced some small amounts of oxygen, likely less than one percent, but since oxygen is so reactive it likely would have been oxidized on the surface by weathering processes. The increased oxygen production was probably the result of two different pathways. The first could have been the reaction of ultraviolet radiation/light with the newly formed oceans and the second could have been an increase in photosynthesis.
Considering that the Earth had no ozone layer, ultraviolet radiation would not have been hindered and affected the surface of the planet. This however may have helped to form the atmosphere as ultraviolet light could have caused photochemical dissociation with the water and split up water molecules to produce some oxygen. The amount would have only been about one to two percent of the current levels but that would also have begun the formation of ozone. At higher altitudes, the oxygen would have further been affected by the ultraviolet light and formed ozone molecules which would have begun shielding the surface.
Once the surface had some protection, cyanobacteria and simple plants would have been able to reproduce/form more readily. With an atmosphere rich in carbon dioxide, they would have had all that they needed for photosynthesis and to begin producing much more oxygen that slowly became a larger constituent of the atmosphere. The carbon dioxide which was present would have slowly been consumed by the plant and bacteria. It is believed that the oxygen levels of the current atmosphere were achieved about four hundred million years ago so the photosynthesis process took between one and two billion years to reach its current level of oxygen.