You’re right what counts as “nice restaurant” depends a lot on perspective.
So here’s some perspective: My entire home country has 6 Michelin star restaurants. Of those, 1 is in the capital which is the home town I’m comparing above.
Whether that means you're eating better food on a regular basis in SF than in many other less dense urban areas in the USA (nearly all are less dense) is a different question, though: and the truth is, you're not.
Places with stars don't have the economic situation I discussed: they have the money to really go beyond their surroundings.
The thrust of my argument is that there’s more of everything in a bigger city. As such you have more options and more competition.
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.
None of this speaks to whether or not SF has more to offer you than other less dense cities in the US, so many of which have excellent restaurants and, indeed, better restaurants. I was very impressed with the food in Austin on a recent visit, for example. Perhaps if SF had continued on the high density curve while maintaining affordability (as Tōkyō has done) it would be a different story.
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.
So here’s some perspective: My entire home country has 6 Michelin star restaurants. Of those, 1 is in the capital which is the home town I’m comparing above.
SF has 7 restaurants with 3 stars.