Some cyanobacteria ancestors had a random mutation that caused them to free oxygen from a water or CO2 molecule, creating a free oxygen atom. The bacteria that could tolerate the oxygen being free was able to create baby bacteria that could also tolerate that little bit of oxygen.
As time went on, more and more free oxygen built up and the bacteria that could tolerate it (through random mutation) were the only ones able to create more baby bacteria, so the new baby bacteria was able to tolerate more oxygen.
That cycle repeated for many generations, we call the process “survival of the fittest.”. The survival of the oxygen tolerant babies is known as ‘selection’ of the fittest.
Latest Answers