Thanks for the great question.
To answer your question, we have to go back to
the formation of the Earth itself. Around 4.54
billion year ago, the Earth formed through a
process called accretion. This is when dust
and gas in space are pulled together by their own
gravity, which in turn pulls in more dust and gas
until the planet is formed.
The Earth’s first atmosphere was made of the
same gas that was present in the solar nebula, or
the cloud of gas and dust in which the sun formed.
This first atmosphere was made of water vapor,
methane, and ammonia. You would not want to
breathe this air.
Next, the eruption of many volcanoes put huge
amounts of carbon dioxide and nitrogen into the
air. Then, 3.5 billion years ago, the first life
on Earth evolved. This is very important to the
future of the atmosphere, especially when
bacteria 2.5 billion years ago evolved to
convert the carbon dioxide into oxygen, which
had not been a part of the atmosphere until this
Today our atmosphere is still about 80% nitrogen,
with about 20% oxygen, and trace amounts of other
gases like carbon dioxide, which plants still use.
The atmosphere is still changing, however,
especially as humans put back a lot of the carbon
dioxide that previously locked up in oil and coal.
This is what’s causing global warming.