Multiple people pointing this out, and absolutely right.
Some question though of how all the research grants do kind of cross-subsidize the education in a way as it pays for research professors, their graduate staff, etc? Otherwise why do we collocate research and teaching?
Also, pragmatically, it's a system that has yielded incredible ROI since WW2, in terms of new industries, new companies, jobs, science, economic gains, productivity gains, and national security. The US university system is the envy of the entire world, and it's being targeted for dismantling by very petty, cruel, and incompetent people.
Because we want the same scientists who do, or recently did, advanced research to teach students? Because we want students to be involved in actual real genuine cutting-edge research? I suppose this is the logic.
As a student back in the day I worked in a university lab, and it was pretty interesting to play a role in solving problems that don't have answers in the end of a textbook.
We did so because having all laboratories be government run was inefficient so in WW2 we decided to split the costs with private and public universities who will maintain labs, equipment, and the federal government will pay directly for the research.