Gene-environment interaction with regards to educational attainment has received increasing attention during the last few years. However, the potential interdependence between different types of environments in gene-environment interaction models has mostly been neglected. Using high-quality register data for an extensive panel of Swedish twins, born during most of the twentieth century, this study explores how genetic propensities for educational attainment, as measured by a polygenic index, interact with both macro-level institutional and sociopolitical context, and with socioeconomic background. The analyses, which combine between-family and causally robust within-family models, suggest that the average association between genetic propensities and educational attainment has increased in Sweden during the twentieth century, along with the expansion of the educational system and decreased economic inequality. There is also evidence of a positive interaction between genetic propensities and socioeconomic background, but only in the oldest cohorts in the sample, and that were born before the Swedish welfare state had been fully established. This implies that micro-level gene-environment interactions can be significantly dependent on macro-level context, an insight that has arguably not yet been given sufficient attention in the literature. Acknowledging limitations of polygenic indices, and the arbitrariness of the genetic lottery, the results may nevertheless indicate a development towards higher equality of opportunity in Sweden during the twentieth century.