(details are from memory, so let's not quibble and argue over them, my autistic friends)
Back in 1906, after the Big Earthquake happened in SF, the US Congress took pity on the city of SF and built the Hetch Hetchy dam to provide the City with reliable water supply (so the City wouldn't burn down again in the next one). The dam would also generate electricity, and that power came free (except for transmission costs, because the City owned the generation infra). So they started to lay the power lines from Hetch Hetchy to SF.
But, as it just so happened, they ran out of wires and poles just before they could reach SF. So PG&E got the contract to finish off the last mile to the City.
And after it was all over, someone found the missing materials lying in some warehouse, rusting away...
Electricity does not have to cost so much in SF, given that generation is free. And yet we pay over $0.50/KWh in the City.