I think there was a study done where they found that schooling outcomes (PISA performance) correlated strongly (but not universally in all countries) with how well teachers were paid relative to other professions in the country. This seems to indicate that teacher quality is important, and that in a few exceptional countries, teachers are willing to be both talented but underpaid (maybe they get great pensions, holidays, other benefits, prestige, etc).
Other studies found that population density is an important factor (the denser, the better). There are some hypotheses here:
(1) Dense populations allow for splitting of ability groups (streaming). This gives better education for both high ability and low ability children.
(2) Dense populations make it easier to provide education per unit of expenditure (fewer schools needed to cover all students).
(3) Densely populated areas tend to be more socially competitive, so students work hard because they know the competition is going to be tough when they grow up.
GDP per capita is a huge factor (as might be expected) for country-to-country comparisons. Student family income is a huge factor for student-level studies.
Biological parents' academic performance is a big factor (heritable intelligence). If you use adopted-children as a dataset to control for all things other than genetics, you can quite strongly support the biological heritability of academic intelligence hypothesis.