SF, and much of the rest of the Bay Area to a lesser (or greater, on the case of Marin) extent had a notoriously high cost of living before “Silicon Valley” was more than a small part of the South Bay.
It's more than tech work that has drawn people to SF, and that combined with supply restrictions that also aren't driven by the tech workforce have kept prices high since before the tech workforce showed up.
Going back to say 1950’s and it was still the workforce pushing up cost of living. Who those people are and what they are doing is a function of the time period, but people want to live there in large part due to the weather etc.