I live a block from my library. Parents take dozens of books home to read to their kids. They don't have to buy them. It would be VERY expensive to buy hundreds of kids books per year. A well informed society benefits everyone.
If you already pay for internet, have a computer, have a college degree, buy books on amazon, live in a big city around well-educated individuals, you might not need a library, but you didn't get any of that for free. It cost a lot of money to get you to that point. Not everyone has that.
The costs of self-educating without a library would be very high for someone without means. If you just factor cost of computer, internet fees and time it would to search for and acquire low cost/free materials (books are cheaper to carry, require no electricity) it's easy to see that it's not a close comparison.
Our problem is that many people can't visualize the benefits of a library until they are in economic turmoil (library use increased during the recession). We don't need fewer libraries, we need more people reading.