There was a brief time post WW2 in the US where housing was affordable. Prior to WW2 housing was extraordinarily expensive and people saved most their lives to buy a house, then lost it during the Great Depression. Most people lived in generational homes or were largely housing insecure. Most of the world never experienced the home glut we experienced in the US post WW2, that has tapered off in the last 20 years. However to be completely fair, we are only talking about a small number of cities on the coast that are unaffordable.
I also see this complaint from 2nd+ generation Americans. The 1st generation immigrant families I know save their money meticulously and end up buying one, two, three houses and renting them out. They do this amazing feat by saving almost all of their income and forgoing all luxuries for 10 years, then renting the rooms of the house they buy out, using the income to buy the second house that’s rented out, etc. They live a life of wise frugality, never drinking an espresso drink or watching Netflix, and scrupulously managing their income and savings - on accountant and K12 teacher incomes. The truth is you can buy a place for $700k in say Seattle for $140k down payment, which if you save 50% of your net income making a dual income of $120k/year takes less than 10 years.
Read the Jungle for a sense of what housing felt like pre-WW2. Compare it to what I described above happens today. Ask yourself what specifically is challenging you compared to other succeeding at it today and those succeeding at it 100 years ago. Maybe hold the post war era as a blip and outlier, and draw a line between you and the past without letting the outlier dominate your perception of your lot in life. Or move somewhere other than San Francisco.