the earth's surface was originally molten for millions of year - there was no atmosphere. eventually the surface cooled and a thin crust formed but volcanoes kept erupting, releasing gases from inside the volcano. the 'degassing' released a lot of carbon dioxide, but also steam, methane and ammonia