UK and Germany are countries where family determines a heck of a lot of how good children are going to perform on math and science. I am not sure if that is good or bad, though. Clearly, is bad if children with potential are discoraged to study and brought down to an appalling average by school public system.
How does investment affect quality education? The answer is nothing.
Not even class size seems to have a meaningful correlation with test scores:
So, what is it then? what improves student test scores? According to this paper, school autonomy, centralised exam, privately operated schools and probably incentives, that is, a clear link, for parents and students, between school performance and higher salaries.