Grad students usually don't pay the tuition themselves, but someone often does. In the sciences, this often comes in the form of training grants from the NIH or NSF at the beginning of grad school, followed by individual grants to the student (e.g., NRSA) or advisor later on. Some people also get funded by private foundations.
These funders aren't going to pay $1M per student, but they might very well pay $40k. So...the university sets tuition at $40k, takes that money when it can, and waives it when it no one else will cover it. Clearly, some kind of funding is required to put on courses, organize seminar series, and things like that.
None of this is to deny that academia is broken in many ways, but it's not broken in the way you are claiming.