Recent studies have characterized how host genetics, prenatal environment and delivery mode can shape the newborn microbiome at birth. Following this, postnatal factors, such as antibiotic treatment, diet or environmental exposure, further modulate the development of the infant's microbiome and immune system, and exposure to a variety of microbial organisms during early life has long been hypothesized to exert a protective effect in the newborn. Furthermore, epidemiological studies have shown that factors that alter bacterial communities in infants during childhood increase the risk for several diseases, highlighting the importance of understanding early-life microbiome composition. In this review, we describe how prenatal and postnatal factors shape the development of both the microbiome and the immune system. We also discuss the prospects of microbiome-mediated therapeutics and the need for more effective approaches that can reconfigure bacterial communities from pathogenic to homeostatic configurations.