As a PhD student in a US university, my tuition fees are ~44,000 USD per year, despite the fact that I don't take any class: only 6 classes are required during the PhD program, and I've completed them during the first two years. Why are tuition fees so high? (tuition is paid by fellowship / RA / TA / ...)
I think it is essentially a scam. There are essentially 3 types of students (1) self funded, (2) departmentally funded, (3) externally funded. For departmentally funded students the tuition fees are essentially meaningless and just represent money being shifted around internally. Self funded students can be really hurt by large tuition fees, but departments can offset these fees by partial departmental funding (again just internally transferring money around). The scam comes when students are funded externally and the external funder is required to pay the full fee (and potentially even indirect costs on the tuition fees). Things get messy when the funding has a cap on tuition fees. For example the NIH NRSA pays 60% of the tuition up to $16,000 plus a $4,200 "institutional" allowance. Most departments I am aware of offer a tuition subsidy to individuals who get an NRSA.
It is worth noting that high fees not only puts PIs at expensive universities at a disadvantage (okay to be fair, it reduces their advantage) in that their research is more expensive than someone at a cheaper university, but it also puts them in an ethical dilemma. When tuition fees make hiring a PhD student more expensive than a post doc, it is hard for a PI to justify hiring a PhD student.
Because, as you mentioned, they are paid for by someone other than you. This happens in any subsidized industry/system. Interestingly, the subsidies grow over time instead of shrink -- the reasons beyond that are something you should ask an economics professor; it is a distinct trend.
You'll find folks who say this is the way things should be as much as you'll find folks who think its a scam. It is a logical outcome of the current academic system, may be a leading indicator of its eventual demise, and at the moment is something you should probably not dwell on unless you happen to actually be an economics postgrad (in which case I doubt you would have posed the question in the first place).
There are costs to you being on campus and using university resources whether you sit in a lecture or not. True, my non-lecture years were a lot cheaper for the university, but that doesn't mean the costs were zero.
My university required me to register for place-holder Research and Dissertation courses which never met so that they would have some way to account for how much to charge me. My real courses and these fake courses had the same per-credit-hour charge (more or less). Imagine if you only had to pay for the real classes that actually met. Your tuition bill for the first couple of semesters would have been $100,000 to $150,000 and then your later semesters maybe only a few thousand. This is pretty imbalanced and hard to justify to some people, so many universities average the costs across all their students rather than piling it on the ones that have lectures. It's not the only model (see Aru Ray's comment about Rice), but it mostly works out.