Modern science needs a lot of skilled labor to do not particularly exciting jobs. Pipetting, building devices, coding, running tests. Arguably they are creating a lot of value for the PIs they work for: progressing their careers, bringing grant money to the lab and the university, creating knowledge for society.
Grad students provide this labor much more cheaply than the value they create. Graduate students are paid around $40k a year but it’s much much less than the same smart ambitious people would be making in a real job. The explicit deal is that you get non-monetary compensation. You do get a credential at the end of grad school. The assumption is that this credential is incredibly valuable but that deal has broken down.
This system is problematic for several reasons.
There are several theories about how this system came about. Like any Complex System, the real answer is probably “a bit of each of them.”