Part of it is the monetary allocation. Property taxes are the primary school funding mechanism, and they allocate the most money where it is least needed.
Part of it is socioeconomic. We allocate the same amount of money as much smaller countries with more homogeneous populations and much less poverty.
Part of it is societal. The best scores come from societies that value teachers and knowledge. Having a large anti-education population hurts your chance of educating effectively. If you segment the US into different areas, you find that the Northeast is more competitive with world scores while the Southeast is vastly worse than even these averages suggest.