A representative sampling of locations of the "head office" from small software businesses that I'm socially close to: Ogaki, Philadelphia, "way in the boonies in West Virginia", "way in the boonies in Idaho", "way in the boonies in Florida", Nuremberg, a small town in Italy whose name I am blanking on, etc etc.
There exist plenty of happy software companies in the big metropolitan areas -- and God bless them -- but they aren't the whole of the solution space.
[+] Why? Interesting question. Some days I think this is just a pure coincidence and some days I think that the low implied burn rate for the founders and generally low opportunity costs makes it easier for the business to hit both pro-forma profitability and "successfully outcompetes best available alternatives on the local labor market" profitability. Bootstrapped businesses can, of course, pay for an apartment in the Mission and exceed a Google PM's salary in Mountain View, but those are much harder bars to hit than "beats the snot out of any job available in Ogaki."