And there's indeed a great variety of quality available on those books. Great and very bad. Consumers don't suffer because of this, at least I don't, in fact I've recently discovered a bunch of out-of-print out-of-copyright mathematical works that are so much better.
Also I got pirated Anthony Horowitz books (I have the originals, but 30 year old book and all. Plus it's in the attic), that are much better than the originals at this point.
The thing is when it comes to actually making texts and culture available, libraries and librarians (and archive.org), and indeed piracy are generally the highest available quality. Why? Because there's no alternative. Once 2 or 3 years pass, copyright owners forget 99% of their stuff and just refuse to make it available. Expected profit is just too low (this goes 10x against publishers, who often take books out of print against the wishes of authors). So libraries are the only quality available, and I much prefer that over the black hole copyright owners present ...