The Earth formed approximately 4.6 billion years ago. Scientists cannot be certain about what gases made up the Earth's early atmosphere. Ideas about how the atmosphere was produced and how it has changed have developed over time as new evidence has been discovered. There is still not enough evidence for scientists to be certain.
One theory suggests that the early atmosphere came from intense volcanic activity, which released gases that made the early atmosphere very similar to the atmospheres of Mars and Venus today:
Volcanic activity also released water vapour, which condensed as the Earth cooled to form the oceans. Nitrogen was probably also released by volcanoes which gradually built up in the atmosphere because it is unreactive.