Microbes providing public goods are widespread in nature despite running the risk of being exploited by free-riders. However, the precise ecological factors supporting cooperation are still puzzling. Following recent experiments, we consider the role of population growth and the repetitive fragmentation of populations into new colonies mimicking simple microbial life-cycles. Individual-based modeling reveals that demographic fluctuations, which lead to a large variance in the composition of colonies, promote cooperation. Biased by population dynamics these fluctuations result in two qualitatively distinct regimes of robust cooperation under repetitive fragmentation into groups. First, if the level of cooperation exceeds a threshold, cooperators will take over the whole population. Second, cooperators can also emerge from a single mutant leading to a robust coexistence between cooperators and free-riders. We find frequency and size of population bottlenecks, and growth dynamics to be the major ecological factors determining the regimes and thereby the evolutionary pathway towards cooperation.