Sure, but you can get that same house for a fraction in many other places. Basic comparison from Nerd Wallet shows median 3bed 2bath in Los
Angeles to be $1.25 mil and same property in Little Rock (most expensive in AK) is only $440k. At a 6.5% mortgage rate (current is >7.5% for 30 yr fixed) that's a monthly difference of $5,200/mo ($8k in LA vs $2.8k in Little Rock) just in mortgage, doesn't even account for other escrow costs, maintenance/updates, or other CoL. That's over $60k/yr difference that could be invested. After 30 years you've got over $5 mil on $1.8mil in principal at 6% returns.
IRL example, I've talked about my house enough, but our mortgage is around $550k in a "large" midwest metro. Per Zillow, comparable houses in LA area right now (4-5k sq ft, 4-5 bed and bath) range from a low of $2.4 mil in Porter Ranch, CA (I know nothing about this place) to ~$7 mil. At 6.5% mortgage rate, you'd pay $3,500/mo where I'm at vs $15k-44k/mo in LA. That's just the difference in mortgage payments. Even at the low end that's a difference of $138k/yr and at the high end you pay less in a year here than you would in a month there ($42k vs $44k). Invest the $138k and you have $11.2mil on $4.1mil in principal at 30 years at 6% interest. At 8% interest you've got $16.2 mil.
You can look at the house as an investment, and from that perspective it may or may not be a good one. Cities, towns, and neighborhoods can shift significantly and is likely more of a gamble long-term than market investments. It's also typically a lot easier to shift funds invested in the market than to move. Obviously there's more flexibility when you've got very high income like Merovinge pointed out, but it's not like you can't hit that income level outside of Cali doing similar work.
Eh, in med school in the midwest I knew a couple psychiatrists in different groups making upper 6 figures or clearing 7 figures piecing various jobs together. I rotated with 2 of them. Per most of the groups that do physician income surveys pay is actually highest in the midwest and south and rural(ish) locums can make bank. People have posted FTE positions in the midwest clearing $500k on here. Cali pays better than some places, but from the stuff I get and have seen on here it's not really that different especially when you factor in CoL.