Where did the oxygen in the Earth's atmosphere come from?
Literally, it is the waste product of cyanobacteria, also known as blue-green algae.
Between two to three billion years ago, Earth's atmosphere started changing.
Organisms living then were doing so anaerobically (without oxygen), but there was a gradual build up of oxygen in the atmosphere - the reason for this, as well as for the percentage of oxygen stabilising at around 21% is still unclear.
What we do know is that tiny organisms known as cyanobacteria (or blue-green algae) would photosynthesise carbohydrates for their nutrition and growth using sunlight, water, and carbon dioxide.
The waste product of photosynthesis, till today, is oxygen.
Over time, this oxygen increased till it reached the levels that we experience today.
The chloroplasts in today's plants are symbiotic cyanobacteria that continue the same process started billions of years ago.