The maxim that no one goes into a PhD to get rich is true, but at the same time, no one goes into a PhD to be unemployed or to become a teacher. Theres no reason to invest a decade doing primary research when an undergraduate with a masters in teaching will suffice.
I know many people that did a PHD on the sole basis to become a teacher as this was the best they could aim for in terms of pay/benefits.
And while I agree that there's high variability in quality of work, both between and within disciplines, I would argue that there have been mountains of really fundamentally useful things that have come out of CS academia (and EE / computer engineering academia to support it), both historically and recently. Everything from programming language theory and optimizing compilers, to modern computer architecture, to all of the fundamental algorithms and data structures, to the basis for modern machine learning and distributed systems and ... I could go on. Industry applies and polishes it, but (in my experience at least) there's simply no way that most of industry would tolerate the multi-year risky projects that lead to useful breakthroughs.