Plants - the early earth atmosphere contained lots of hydrogen and helium. Over millions of years that escaped from the atmosphere because of it's light weight, and was replaced with carbon dioxide from outgassing rocks, and water vapor, possibly from meteors. As plants began to proliferate about a billion years ago, they fed on carbon dioxide, as they do today, generating oxygen as a byproduct.