The really dumpy hotels have no choice. Their plant is run down, and they may be a no-name. Unless they offer free amenities, nobody in their right mind is going to stay at their place (assuming similar nightly rents) unless there's no choice.
I'd say that the really dumpy hotels are just badly managed. Yes, it costs a bit more to keep your facilities maintained and properly cleaned as opposed to let everything run down, but nothing like the 2-3x increase in price that you'll typically pay at a decent hotel compared to a dump. The hotel might need to have a bit more cost for cleaning and maintenance personnel, but the cost is seriously not that high, and it makes sense to aim for repeat business.
As an example: one of my nicest stays was five nights at a nine-room B&B in Edinborough, run by an elderly widow (not active anymore, she probably retired) . Although the building was old and creaky the staff (one girl) was very friendly and helpful, the rooms were spotlessly clean, they had a cosy library-ish common room with a fireplace constantly lit in the evening, and the landlady prepared a home-cooked breakfast every day (brought to you in your room if you were to badly hung-over from sampling lokal whisky the previous night, regardless of whether you really wanted it). The price was £23/night. They made a good bit of extra money by providing simple food and drinks in the evening, but that was also at a reasonable price.
The point is that as they managed to make money (they did, I asked) running a pleasant establishment at budget prices, there's no reason why any dump motel shouldn't be able to convert into a nice place to stay while keeping a similar price point. No, they might not be able to provide shirt press and shoe polishing included (although I'm quite confident that the landlady at the mentioned B&B would have done that at no extra cost), but they *can* keep the place clean, have helpful and service-minded staff, and generally be not-a-dump at a budget as long as they have proper management that cares.
PS my keyboard has a marginal 's' key, apologies if I missed any of them.