Take a cloud of molecular hydrogen add some turbulence and you get star formation thats the law. The efficiency of star formation (how big and how populous they get) is largely a function of the density of the initial cloud.
At a galactic or star cluster level, a low gas density will deliver a sparse population of generally small, dim stars while a high gas density should result in a dense population of big, bright stars. However, overlying all this is the key issue of metallicity which acts to reduce star formation efficiency.
So firstly, the strong relationship between the density of molecular hydrogen (H2) and star formation efficiency is known as the Kennicutt-Schmidt Law. Atomic hydrogen is not considered to be able to support star formation, because it is too hot. Only when it cools to form molecular hydrogen can it start to clump together after which we can expect star formation to become possible. Of course, this creates some mystery about how the first stars might have formed within a denser and hotter primeval universe. Perhaps dark matter played a key role there.
Nonetheless, in the modern universe, unbound gas can more readily cool down to molecular hydrogen due the presence of metals, which have been added to the interstellar medium by previous populations of stars. Metals, which are any elements heavier than hydrogen and helium, are able to absorb a wider range of radiation energy levels, leaving hydrogen less exposed to heating. Hence, a metal-rich gas cloud is more likely to form molecular hydrogen, which is then more likely to support star formation.
But this does not mean that star formation is more efficient in the modern universe and again this is because of metals. A recent paper about the dependence of star formation on metallicity proposes that a cluster of stars develops from H2 clumping within a gas cloud, first forming prestellar cores which draw in more matter via gravity, until they become stars and then begin producing stellar wind.
Before long, the stellar wind begins to generate feedback, countering the infall of further material. Once the outward push of stellar wind achieves unity with the inward gravitational pull, further star growth ceases and bigger O and B class stars clear out any remaining gas from the cluster region, so that all star formation is quenched.
The dependence of star formation efficiency on metallicity arises from the effect of metallicity on stellar wind. High metal stars always have more powerful winds than any equivalent mass, but lower metal, stars. Thus, a star cluster or even a galaxy formed from a gas cloud with high metallicity, will have lower efficiency star formation. This is because all stars growth is inhibited by their own stellar wind feedback in late stages of growth and any large O or B class stars will clear out any remaining unbound gas more quickly than their low metal equivalents.
This metallicity effect is likely to be the product of radiative line acceleration, arising from the ability of metals to absorb radiation across a wide range of radiation energy levels that is, metals present many more radiation absorption lines than hydrogen has on its own. The absorption of radiation by an ion means that some of the momentum energy of a photon is imparted to the ion, to the extent that such ions may be blown out of the star as stellar wind. The ability of metals to absorb more radiation energy than hydrogen can, means you should always get more wind (i.e. more ions blown out) from high metal stars.
Explore further: Planets with oddball orbits like Mercury could host life
More information: Dib et al. The Dependence of the Galactic Star Formation Laws on Metallicity.