* You can't do it by just buying ebooks because those don't come with distribution rights. This is essentially what zlib does, albeit with ebooks "donated" by others.
* You can't do it with interlibrary loan for the same reason.
* You can't do it by buying a distribution license because some of the largest publishers simply don't sell those.
* You can't do it by purchasing physical books and scanning them into digital equivalents ala controlled digital lending. Internet archive tried that.
The current situation today requires either paying perpetual, recurring licensing fees on every single ebook or piracy. If all we have is the former, libraries will never be able to stock anything beyond a small collection of topical books, as is already the case at most local libraries.