The answer depends on where you live. I am most familiar with what is available in the US.
There are free online libraries of public domain books, such as
Project Gutenberg and the
(MobileRead) Patricia Clark Memorial Library.
Open Library has public domain books from the Internet Archive and also has some scans of newer books available
if your local library participates.
Some public libraries allow access by patrons outside of their usual service area for a fee. Examples are the
Free Library of Philadelphia,
Brooklyn (New York) Public Library, and
Fairfax County (Virginia) Public Library. They make use of e-book lending service providers like OverDrive, 3M Cloud Library, Freading, Axis 360, and Hoopla.
There are also several paid services that allow access to large collections of books, equivalent to a public library. Examples are
(Amazon) Kindle Unlimited,
Scribd and
Playster. (Another service,
Oyster, is shutting down.)