How do you form a habitable planet?
"Rare Earth" is an extraordinary adventure story with lots of scenarios where the conditions for life are in precarious balance. Neither of these sets of authors would claim that their books are the final word on these things, and certainly this treatment is but a brief and tentative overview. Some of the relevant conditions or scenarios are collected below.
Ward & Brownlee
Gonzalez & Richards