This site tells the story of the history of the universe. Click Earlier and Later to follow the story. So far there were no oxygen molecules in the atmosphere .
Some bacteria still live without oxygen today.
Lightening and other energy sources were making new molecules , and this was the food which the bacteria fermented . As they spread they began to run out of food, so they had to find new sources of energy . Some began to eat minerals to get energy which they used to build their own food.