Don't get me wrong, I do appreciate the access that libgen and z-lib provide and think on the whole it is beneficial to society. It is still not paying for people's work though.
As a counterpoint, have you looked at your local library's ebook offerings? Publishers have created a situation where digital books are significantly more expensive than physical copies and expire far more quickly. We're also just coming out of a two year period where physical libraries effectively didn't exist and most library systems hadn't expanded their digital offerings to meet demand.
I still buy books, but these sites have largely replaced traditional libraries for my partner and I because they allow us to read what we actually want instead of Oprah's book club titles or the 50 digital self-help guides my local library stocks with their limited resources. I recognize that they're simply serving what most people want, but the alternative for me is simply not reading recreationally.
The other side of this conversation is that even if we did get rid of pirate libraries there would still be huge, unresolved issues with author compensation. There's been a dramatic decline in how much authors (and the other people directly involved) take home over the past couple decades [1] that has little to do with the marginal number of pirate readers.
A big reason piracy exists is because the functionality of these systems is better than the official channels. There's a reason streaming services led to a dramatic decrease in piracy. There's also a reason that piracy is making a return. Yeah, pirates are picky and they push other services forward.
Don't get me wrong, I do appreciate the access that libgen and z-lib provide and think on the whole it is beneficial to society. It is still not paying for people's work though.