Often Galactus fed on planets with lifeforms, but the lifeforms could leave and he would still feed. Also not every planet he eats needs to have life.
So what is he looking for in a planet?
Science Fiction & Fantasy Stack Exchange is a question and answer site for science fiction and fantasy enthusiasts. It only takes a minute to sign up.Sign up to join this community
After his visit however, depending on how he consumed the energy, it could be barely capable of supporting life or completely destroyed. When he uses his machines to convert a planet, the world usually survives. When he is starving, he absorbs the planet directly leaving nothing but rubble.
Planets without life such as Mercury would not be considered candidates for consumption. Planets past their prime like Mars or completely inhospitable like Venus, would also not be consumed.
A planet with a dynamic ecosystem capable of supporting non-human life or life that barely resembles carbon based life at all is still capable of feeding Galactus.
Once upon a time a planet would sustain him for a century, in recent years a planet could sustain him for as little as a month.
To sustain his immense power, Galactus requires energies derived from a biosphere, a planet able to sustain living beings, though life does not actually have to be present.
Though Galactus can extract and absorb this energy himself, he generally employs his immense Elemental Converter to perform the process, as it is far more efficient and avoids the expenditure required of him. Sometimes the planets on which he feeds are left barely habitable; other times he consumes all life and water, leaving it devastated and barren; most often the process reduces the planet to space rubble.
When Galactus was newly formed, the energy of a medium-size Earth-like planet sustained him for over a century. Now he needs to feed about once a month; in addition, when preparing for a massive expenditure of energy, he may absorb planets more frequently to amplify his power stores.
Conversely, when he does not feed within his allotted time, his energies will dwindle, and he will even begin to physically shrink as they drop dangerously low. His body totally converts the energies he absorbs for his life functions and activities without any waste products.
More on Marvel.com: http://marvel.com/universe/Galactus#ixzz33uJV9owe
You can also see a more extensive entry on Galactus' eating habits on the Stack Exchange entry: What, of the planets he consumes, provides Galactus with sustenance?
During the relatively recent Annihilation storyline, Annihilus and co. imprisoned Galactus and used his energies as planet-destroying weapon. In the panels below it is explained how a planet can be converted into the cosmic energy fed upon by Galactus. This is the closest we ever come to getting an explanation of the process.