How did oxygen come to make up 21 percent of earth's present atmosphere?

The first plants are thought to be the ancestors of green and purple algae. Over several billion years, oxygen began to build up as plants grew in number and diversified.