I would neither buy the house nor take out the mortgage.
The unaffordability problem you are noticing is being faced by everyone, even with today's absurdly low unemployment, which means either interest rates have to fall or house prices have to fall.
If interest rates fall, you will regret taking out a mortgage in the 6-7% range because you'll be paying thousands of dollars to refinance in just a couple of years. If you paid cash, you might regret not investing in long-duration bonds instead of an unaffordable house.
Also, the "rates fall" scenario would typically be associated with a recession, which means your over-leveraged and now unemployed neighbors would be getting foreclosed on, potentially dragging down your property value. House prices rose almost 17% in 2021 - more in HCOL locales - so I think we should be able to imagine prices falling just as far and as fast as they rose.
If home prices fall, you will regret buying a home for cash or with a mortgage. You will have wished you spent another year in an apartment or with roommates, and pounced after the price decline instead of before.
I think we're due for a recession in late 2023 or early 2024. At that time, your $500k could be deployed buying stocks on the cheap, like people did in 2009-2010. Even now, your $500k could be earning 6%, or $30k/year, in a portfolio of investment-grade bonds and preferreds. Such a portfolio would appreciate in a "rates fall" scenario. I'd be a lot more excited about replacing a huge chunk of my spending than I would about a money-pit tract home purchased at a very risky time and at risk of losing six-figures of value.