Currently, nearly 99% of primary production of oxygen comes from eukaryotic algae but prokaryotic bacteria were responsible for forming the oxygen on the Earth. see:
The chart below shows the early events on the planet, including the formation of O2.
CyanobacteriaCyanobacteria, also called blue-green algae, were among the earliest organisms on Earth. These primitive bacteria produce oxygen during photosynthesis as they fix CO2 dissolved in the water. Analysis of RNA and DNA for different organisms shows that all other photosynthetic organisms derived this ability from cyanobacteria through endosymbiosis. Chloroplasts are the remnants of these engulfed cyanobacteria. Photosynthesis was invented once.
Cyanobacteria also fix nitrogen and, although they make up only a tiny percentage of the ocean's biomass, they are the principle agent for nitrogen fixation. Organisms that make oxygen and fix nitrogen have a problem because the enzymes involved in N2 reduction are poisoned by oxygen. To get around the problem, the bacteria expel the oxygen they produce and divide their time in either photosynthesis or nitrogen fixation.
There are many mechanisms to separate O2 formation and N2 reduction. Trichodesmium does photosynthesis in the day time but only does nitrogen fixation at night.
Early Life and Global Climate Change
Early life forms also produced CH4, N2O, CH3Cl, Me2S that had a major effect on global warming. In those early years, the sun was dimmer and didn't provide the solar flux we have today. Methane, produced by microorganisms was the major greenhouse gas. In the low oxygen conditions of the past, the atmospheric lifetime of methane was about 10,000 years instead of the 14 years it is today. The greenhouse effect warmed the surface of the planet and promoted an explosive growth of living things.
This simple organism changed the Earth. There was little free O2 until large quantities of cyanobacteria released it into the atmosphere 2.3 billion years ago. The large input of oxygen also oxidized the methane in the atmosphere, replacing it with CO2, a less potent greenhouse gas. For this reason, the first ice age coincided with the release of O2. The molecular oxygen also oxidized iron on the surface of the planet and created the red, oxidized iron deposits we can see beginning from that era.