Yeah, don't underestimate how much cost of living factors in. Being broke in a city like LA isn't that much better than being very comfortable in Montana.
For med school, and residency especially, it's good to think about commute and parking. It's also nice not to have things be too tight, to easily afford car repairs and other sort of nightmareish things coming up.
I'm known residents that could financially manage having a cheap maid once a week, which can really help.
A yard for their dog, a dogwalker. (I'm not big on having a dog in residency but some people manage).
Saving money can help you fly out and make the most of golden weekends and vacations, too.
Don't underestimate what living somewhere slow and cheap can do for your QOL for the time you're in residency.
Lastly, some of the programs in those sorts of locations are just more pleasant on a day to day basis for a lot of reasons.
I looked at one program in the middle of nowhere Michigan. You know what though? 3/4 of your weekends even starting in intern year were always golden, all year long for the whole residency. People got out early. No one had more than a 15 minute commute in no traffic. Almost everyone lived in a nice and affordable house, whether they rented or were buying. Despite many being married, given there wasn't much else around, the residents were all quite close and spent loads of time together having low key fun, and they had the time to do so.
Was it boring? Sure. Were they overworked and miserable for 3 years? No. Life is a series of trade offs.