In the US, libraries are free, have bathrooms, and you can spend the whole day. Hence, urban libraries have become de facto homeless shelters with all the social problems that implies. Suburban libraries are still pretty great places to work or read, but city libraries are a tragedy compared to what they were when I was growing up.
It sounds like you experienced this in some American city and generalized to all? This absolutely not true for Boston Public Library which is an immensely convenient place to WFH, read, or write. I also never experienced this in NYC public libraries, nor in the main Philadelphia library.
Imho public library systems in US cities are absolutely incredible, and arguably one of the best perks of living in the US period.
That's surely true, but maybe you're generalizing from a smaller sample than I am. For context, I've spent significant time (years) in Boston, NYC (Manhattan, Queens, Brooklyn), LA (West Side and Downtown), and several smaller American cities in the American NE and SE using libraries. For comparison, I've also used the libraries in Paris, Rome, London, and other European cities extensively. I've used the iconic libraries and university libraries and they are great for sure, but branch libraries are a different matter entirely.
They definitely aren't as good as they could be, but I have always been able to get stuff done if I reserve a study room. Even suburban libraries are better like that
What do you think is the "intended purpose"? The fascinating and beautiful thing about the library systems in US is that there is no reason to have a purpose, you can literally just sit down and look outside the window. Breakneck-speed-modern-life needs this. I want a place to stop, think, read, write, listen... just somewhere to be human without fees for a second.