There was little or no oxygen in the early atmosphere. The oxygen that is now in the atmosphere was produced by algae and plants through photosynthesis.
Photosynthesis takes in carbon dioxide and water and, using light, makes glucose and oxygen. The word equation is: carbon dioxide + water → glucose + oxygen. The symbol equation is 6CO2 + 6H2O → C6H12O6 + 6O2.
Algae first produced oxygen about 2.7 billion years ago, and soon after this oxygen appeared in the atmosphere. Over the next billion years plants evolved and the percentage of oxygen gradually increased to a level that enabled animals to evolve.
You can show that aquatic plants produce oxygen in daylight by watching bubbles of gas rise from pondweed in water.