Also kind of important to have teachers that can live within commuting distance of where they are teaching, so CoL ends up pretty important. Even more so if you want teachers that are older than, say, 22 and might have a partner and/or kids so won't want to live in a studio or have multiple roommates.
The median individual income in San Francisco in 2023 was 69,260 USD. The median household income (which may include income from more than one earner) was 141,446 USD.
Many people commute to San Francisco from other places in the Bay Area.
CoL isn't a concern that is unique to teachers. When discussing 'low pay' of a particular job, it's relevant to compare it with other jobs in the same location, which those same people might be able to get.
(Also - there is research (which I don't have time to dig up now) that shows public school teachers who leave teaching tend to earn the same or less in their new career.)
Of course it's not, which is exactly the point. In many places, low teacher pay is predicated on the fact that there are plenty of people willing to accept the low pay because there are plenty of people willing to accept the low pay. That's not true everywhere.
If you want to have teachers at your school, you have to pay them enough to live within commuting distance, subject not just to tolerance of the commute, but you're also in competition with all the communities also within commuting distance. In my experience, aside from usual teacher attrition, Bay Area teachers don't leave for a different career, they leave for a different location, and usually those places need teachers too.