«With physics and math, I could never figure out a way to contribute,» says Stallman, recalling his struggles prior to the knee injury. «I would have been proud to advance either one of those fields, but I could never see a way to do that. I didn't know where to start. With software, I saw right away how to write things that would run and be useful. The pleasure of that knowledge led me to want to do it more.»
Also, there is another argument: nowadays contributing to math means extending some narrow field which maybe a hundred of mathematicians in the world care about. In contrast, software affects a good deal of people and organizations. Even achievements of computer science often have effect in a few years.
For a long time math was essentially more accessible to students than programming. However, that's not an issue anymore, thanks to cheap computers and initiatives like OLPC.
So, I wonder, how an average pure mathematician of XXI century will find his path through the temptation of becoming a hacker?