It would seem that it would be in the interest of book publishers to push for the illegalization of libraries since it appears to harm book sales. After all, instead of purchasing every book I read, I can just go to the library and borrow the books from there. Has there ever been a push to ban libraries by the book publishing industry?
This answer applies to America only, because I am An American Librarian (™) and I only know the historical, professional, and legal situation for libraries here. The answer is kinda yes: publishers routinely oppose some of the work of librarians, and others, in this day and age. The modern problems and restrictions placed on libraries with ebooks can be in some ways seen as adversarial, since they for a time believed ebook circulation would reduce sales of ebooks, they have since changed their tune a bit since 2013. Librarians maybe are even adversarial to publishers... But mostly no, publishers have not been substantially against libraries in any of their historic forms as buildings where people can obtain physical media objects they do not own, either for free through charity, for “free” through public taxation, or through private fee subscriptions. It’s simply not in their best interests - libraries are the single largest purchaser of their products. They sell directly to us and they give us swag at conferences to Facilitate Relationships. And studies show library use correlates with individual book purchases, meaning library users buy more books than non-library users. People who read a lot use the library and people who do not read a lot do not, the public library has a finite budget that cannot meet the exact desires of everyone in town (or have enough copies of Hot New Book for everyone), so really it’s not rocket science that it correlates. Publishers know this. Most books people check out from the library they would have not otherwise purchased.
They also couldn’t do a darn tooting thing about public libraries (or Blockbuster) in the glorious days between 1908 and digital publishing, because of something called First Sale Doctrine. First Sale Doctrine separates the physical object from copyright basically, and means when you have a copy of an intellectual work, you can do whatever you want with its physical carrier without infringing on the author’s copyright or moral rights. I can rip out pages and literally wipe my butt with your Hot New Bestseller and call it an art project if I want, I can pull out all the tape out of a VHS and pretend it’s spaghetti as my second art project, or I can rent random people either of those objects for $5/week, and you can’t do anything about it. I can’t photocopy it, keep my copy, and give someone else the photocopy though, that’s illegal. But First Sale Doctrine is the backbone of (physical) public libraries in America. (Other countries have different legal understandings for author/publisher rights and libraries.) First Sale was, however, not established for libraries, but actually for booksellers! In the words of Joe Fox in You’ve Got Mail, “I sell cheap books, so sue me.” A publisher tried to set a price floor on a book of One Whole Dollar by claiming selling a book for less than they liked violated their copyright, a bookseller undercut at 89 cents, and the publisher was then righteously smacked down for interfering with the glorious free market system. Libraries rode along on this.
Now, of course, libraries existed before 1908, what then? We must look deeper into library history.
The subscription circulating library is the oldest form of populist circulating library, dating from the 18th century. It’s basically Netflix, back in the old days when Netflix was a DVD mailer primarily. They were popular with upper class women, and stocked a lot of popular fiction. These were put out of business by public libraries, over time. (Though they saw a resurgence in the era of physical A/V rentals, Blockbuster, Netflix, Family Video, all those businesses are just fee libraries.) At the birth of the public libraries movement in America, however, we’re deep in the Progressive Era, and free public libraries are for the Public Good, and the Slovenly Masses should Bootstrap Themselves Up through Hard Work and Education etc. etc. Library collections reflected this, and were not stocking popular fiction. Library trustees were hostile to fiction in general, as it didn’t reflect Progressive values, and it’s hard to justify spending taxpayer money on a new socialist enterprise when you’re buying pulp fiction. So what are these new public libraries buying? Shakespeare, history, engineering manuals, crap like that. They were not meeting the pleasure reader, and had no interest in doing so. So you’ve got a bunch of do-gooders buying up your most expensive and harder to sell books, while totally ignoring the cheap and cheerful things you can sell easily? Why fight that, it’s gravy! The public circulating libraries’ threat to the disposable-reading publishing industry was nonexistent, and by the time libraries got into that game (and later into movies, music, and other fun non-book things), we were well post First Sale Doctrine, and they could do darn tooting about the library cutting into their theoretical Harry Potter sales. Not that they’d want to, public libraries are almost universally beloved by Americans, and picking on them is a bad look.
So teal deer is: no, until it became a bit of a yes when they got to neatly escape that annoying First Sale Doctrine by not having a physical carrier, but now it’s going back to “no” again as they’ve realized that ebooks are just like real books, in that the library is the biggest consumer.
Edit: I am feeling guilty for stomping on the 20 year rule with ebook problems, but then I remembered the first ebook was made in 1971, and it's just the publishing industry's interest in them that's modern. But if you want to talk more about the challenges libraries are facing with ebooks I'd recommend you cross post to /r/Libraries - it's an active community and you can meet some librarians at the water cooler for some real library politics gossip.