A public university receives its core funding from the government and the fees paid by the students (actually their parents) - to educate the students. The university then pays the professors (instructors, lecturers, …). The professors teach the students. They also do research, to generate new knowledge, so that they can teach better, for the benefit of the students and society in general. There is a saying about this: research underpinning teaching. It all seems sound and proper.
But, of course, the devil is in the details. If you take a close look. You will find that some professors teach a lot more than others, while some spend most (if not all) of their time in research. In most cases, they are retained and promoted based on their research much more than their teaching. The higher their rank, the less they teach, and the more they research. Perhaps more importantly, the more their power in determining how the university is run and who is promoted. It is a positive, reinforcing cycle.
The government (actually the public that pay the taxes) and the parents pay the university (and indirectly the professors) to teach the students and benefit the society. What really happens in many cases is that the professors research to advance themselves, while the teaching is delegated to the junior staff who remain junior no matter how well they teach. I wonder how much the government and the parents are aware of that.
This is, of course, a much simplified description, leaving out a lot of details and phenomenon that does not fit the description. For example, research does benefit the society, usually in the long run, research professors do not mind teaching research students (who help them produce more research, but not undergraduate students who are no help in research). But this racket is very real in many universities.