In his Life of the Cosmos, Lee Smolin asks, Why is our universe hospitable to life, and why is it full of stars? Smolin proposes that the universe we inhabit is a product of natural selection: Universes have come and gone, but the most successful ones at reproducing, that is, giving rise to new universes, are the ones that are thick with stars.
A universe full of stars will also be a universe full of carbon, the very element necessary for life as we know it. Each carbon atom forms four covalent bonds, and carbon atoms bond with other carbon atoms to form long chains, with and without branches. Lots of different atoms and ions can bond all along such carbon chains. Then the chains twist and circle into a vast variety of shapes. And molecules with charge and shape are the working machinery of living cells.
The first stars in our universe consisted of hydrogen and helium, but as those stars burned out, they produced heavier and heavier elements. Eventually, dying stars exploded into stardust and delivered all 92 natural elements into space. Gravity pulled the stardust together, making it coalesce into new stars, sometimes with planets. One such star is our sun, and one such planet is our earth.
At first the earth was just a huge, probably hot, ball of chemicals, mostly compounds of the 92 elements. Then the earth cooled, and another kind of evolution began. Water condensed into oceans, and some partly-soluble/partly-insoluble molecules turned their insoluble parts away from the water to form infinitesimal, floating spherical membranes.Trapped inside the spheres were various compounds. Many spheres burst like bubbles. But the most successful spheres didn’t burst. Instead, some of their inner compounds produced more soluble/insoluble molecules. These enlarged the membrane until a sphere split into two spheres. To do this, the material inside would need energy, perhaps from the breakdown of other enclosed compounds. Over time, some successful spheres developed ways of taking in more compounds from the ocean to break down for energy or to use in manufacturing more membrane. The longer such spheres were around, the more new, useful compounds they were able to take in or manufacture, and the more useful internal structures they were able to develop. Until eventually some of the spheres actually became very primitive cells, somewhere between life and non-life. This set the stage for yet another evolution: that of living organisms.