It is true that libraries are a public benefit the government is not obligated to provide, just like fireworks displays and hiking trails. But once the government chooses to provide a public benefit, there are limits on how it can restrict use of that public benefit.
Speech is not food. We have excellent medical, scientific, and legal definitions of food. The various welfare programs remain fairly hands-off about making sure benefits are only used to buy "good food." They do not, for example, require recipients to only buy kosher food or only buy those kinds of food mostly grown in states controlled by whichever party is in power - cherries and avocados for Democrats, beef and corn for Republicans. Nor do they do the converse, prohibit use of the benefit based upon religious or political leanings.
By putting filters on public library computers, we would be spending resources to restrict access to certain kinds of speech because we don't like that speech. The government can't restrict speech, or access to speech, just because it doesn't like it. It could never do so fairly.