Adversity during childhood can limit children's chances of achieving their optimal developmental and psychological outcomes. Well-designed observational studies might help identify adversities that are most implicated in this, thereby helping to identify potential targets for developing interventions. To compare the association between preventing childhood poverty, parental mental illness and parental separation, and the population rate of offspring common mental disorders (ages 16-21 years) or average school grades (age 16 years). A population-based, longitudinal cohort study using Swedish registries was conducted. A total of 163 529 children born in Sweden between January 1, 1996, and December 31, 1997, were followed up until their 21st birthday. They were linked to registries using Sweden's national personal identification number. Children were linked to birth parents, hospital records, and school data. Parents were linked to registries containing health, income, sociodemographic, and obstetric data. Analyses were conducted between January 10, 2021, and August 26, 2022. Childhood adversities of relative poverty (household disposable income <50% of the median), parental inpatient admission for a mental illness, or parental separation. Adversities were categorized into developmental periods: ages 0 to 3, 4 to 7, 8 to 11, and 12 to 16 years. The main outcomes were children's hospital records with a diagnosis of anxiety or depression between ages 16 and 21 years and school grades at the end of compulsory education (age 16 years). The parametric g-formula modeled population changes in outcomes associated with the counterfactual, hypothetical preventing adversity exposures, accounting for fixed and time-varying confounders. Adjustments were made for parental demographic characteristics, obstetric variables, and socioeconomic data at birth. A total of 163 529 children were included in the cohort (51.2% boys, 51.4% born in 1996). Preventing all adversities was associated with an estimated change in the prevalence of offspring common mental disorders from 10.2% to 7.6% and an improvement in school grades with an SD of 0.149 (95% CI, 0.147-0.149). Preventing parental separation provided for the greatest improvement, with an estimated 2.34% (95% CI, 2.23%-2.42%) fewer children with a common mental disorder and an improvement in school grades by 0.127 SDs (0.125-0.129). Greater improvements were shown by hypothetically targeting adolescents (age 12-16 years) and those whose parents had a mental illness when the child was born. The results of this cohort modeling study suggest that preventing childhood adversity could provide notable improvements in the rates of common mental disorders and school grades. Many children might achieve better life outcomes if resources are properly allocated to the right adversities (parental separation), the right groups (children with parental mental illness), and at the right time (adolescence).