Github mainly succeeded because of the various shortcomings in Gits command line interface. Github made certain models of cooperative development incredibly easy, and since most or almost all of the open source development is just that the time was 100% ripe for something like github. Still, it is an incredible achievement and I hope that github will be around for a very long time to come. For a laugh: http://svnhub.…
I'd say GitHub mainly succeeded because it put code first and overall focused on a great experience for developers to contribute and collaborate. SourceForge, in contrast, was heavily influenced by consumers wanting to download the latest version of FileZilla or some Linux games.
And Google Code, for the brief time it was the main event, took things too far the other direction from SF. It was just too terse and the design too raw, as was customary for Google back then. It actually had the basis for a lot of the critical functionality, but lacked the kind of design flair GitHub has shown. I don't think it was ever seen as a potential profit center, so always seemed starved of the resources to compete with GitHub.