The heterotrophic hypothesis asserts that the first living beings were the fermenting heterotrophs. Fermentation released carbon dioxide (CO2) and then the atmosphere became enriched by this gas. By mutation and natural selection organisms capable of using carbon dioxide and light to synthesize organic material appeared. These would have been the first photosynthetic beings (that were also fermenting beings since there was no abundance of oxygen).
Since photosynthesis is a reaction that releases molecular oxygen, with the emergence of fermenting autotrophs this gas became available. Some organisms then developed aerobic respiration using O2, a highly efficient method to produce energy.