Gut immune function conditions the development of local and systemic diseases that result from defects in immune regulation, such as inflammatory bowel disease, allergy and obesity. As epidemiological studies support the developmental origin of health and disease, deciphering the critical factors modulating gut immune development should allow the advance of primary prevention strategies specifically adapted to the early-life immune system. Here, we will review gut mucosal immunity development and cover in more detail the recent understanding of the impact of early nutrition on this process. We will emphasize how nutrition can shape microbiota composition and metabolic function and thereby the production of metabolites with immune-modulatory properties. We will also focus on the role of dietary compounds recently demonstrated to be essential in immune development and function, such as dietary antigens, vitamin A, and aryl hydrocarbon receptor ligands. Finally, we will discuss that early-life physiologic food for mammals contains factors capable of compensating for neonatal immune deficiencies, but also factors that are decisive for immune maturation towards a maternal milk-independent and efficient immune system.