Real estate and rent in Cambridge is substantially cheaper (2x?) than anything in Silicon Valley, and Somerville is even cheaper. Some of Somerville is rough, sort of like Oakland, but areas of it (like Davis Square) have all the benefits of Cambridge. Admittedly, you're a few subway stops (say, 5-10 minutes difference) further away from Boston.
The other major difference is the weather. If you don't like snow, living here sucks. But, if you like the winter, I think Somerville is a win.