Sure, if you're married and have a second income, then that second income is basically subsidizing education. My wife was a teacher and retired when our kid was born, because we could. Some time in her 50s she'll be able to draw her pension.
But basically the only reason we can afford to live in the Silicon Valley is because I'm an engineer with a decent salary. A lot of her paycheck went right back into her classroom, and with the hours she worked, she was basically make $3/hr, despite getting some of the highest teacher pay in the country.
And all of her coworkers were in the same boat -- almost every one of them, even the senior teachers, were married to engineers. The few that weren't either had family money or at least had parents who bought them a condo or house. Or a good friend. We let one of her young teacher friends live with us for a couple years until she managed to save up enough for a down payment on a small condo, and then got married and got a second job.
It is basically impossible to be a teacher in Silicon Valley without a highly paid spouse or multiple side hustles.