The competition means that a lot of places scraping by in smaller cities can’t make it in a bigger city. In theory that means median quality is higher.
And even a 3-star restaurant won’t survive in a place that doesn’t get enough well-to-do visitors to sustain it.
For a more casual perspective, SF has 126 restaurants on the Michelin list (not all hve stars). My entire home country has 52.
Quality food has more to do with agriculture and supply chains than money or density per se -- good salad is not something you can buy if no one is growing it -- and more and more areas in the US have made the transition to that kind of farming and production.
Now challenging SF on grocery stores -- that's another matter. They are drawing on deep roots, there.
Places with stars don't have the economic situation I discussed: they have the money to really go beyond their surroundings.