The planets atmosphere did not always contain oxygen. Oxygen photosynthesis is the process responsible for producing oxygen on Earth through the splitting of water molecules.
Geo biologists has found evidence of a cyanobacteria is the first group of organisms to release oxygen into the environment via photosynthesis. Water-oxidizing or water-splitting photosynthesis was invented by cyanobacteria approximately 2.4 billion years ago and then borrowed by other groups of organisms. Algae borrowed this photosynthetic system from cyanobacteria, and plants are just a group of algae that took photosynthesis on land