San Francisco marathon isn't generally regarded as an elite event, let alone "famous". Most metropolitan road races are around this price point. Especially pricier the closer you register to race-date.
But to your point, there are many smaller races that are cheaper. But often these are less organized, fewer road closures, less exciting, fewer perks; you get what you pay for.
I mean, presumably for every New York Marathon and Boston Marathon, there are 100 less famous events that can't command such a high price?