What is this obsessions with leaving something behind, or doing something noteworthy? Be selfish. Programming is my selfish pleasure; I love it therefore I do it.
Just remember, we are a tiny, insignificant speck in the history of our own planet, let alone the universe. If you truly believe you can improve people's lives with code, go do that. But don't make it about proving yourself to other people, or creating a lasting legacy. Ask yourself, if everything I made or affected disappeared when I died, would I still be doing this?
For me it's not ego, well not primarily I like to think. I find, after programming for 30 years now, that programming is deeply flawed and that it is basically a huge disaster waiting to happen (in many cases it's happening already). I want to try to at least progress the field a little bit further so it's not this bad anymore.
It's a way of coping with our limited lifespan. The thought of leaving something behind gives people a sense of comfort that they may live on in some capacity when they pass. The truth is, even if you do something impactful, future generations will often take it for granted or overturn your work in making progress. No one escapes the bleak nature of our existence. No one.
Maybe that’s exactly the issue. Statistically no one will leave behind such a legacy as Pythagoras, but we judge ourselves by the success of those who have anyway.
That's only a few thousand years ago. What about 10 thousand years in the future? Those kind of discoveries only seem great because we are so stupid. Future generations will not look up to a "great idiot" just because he was great.
But it's a different kind of selfish. I'm specifically speaking out against megalomania and narcissism, which are really the root causes I think you're concerned about. You should be selfish in the sense that you shouldn't feel that you owe something to society in order to be happy. Anything that you gain an intrinsic sense of happiness from is worth doing, as long as you aren't hurting or negatively affecting others by doing it.
Just remember, we are a tiny, insignificant speck in the history of our own planet, let alone the universe. If you truly believe you can improve people's lives with code, go do that. But don't make it about proving yourself to other people, or creating a lasting legacy. Ask yourself, if everything I made or affected disappeared when I died, would I still be doing this?
Fight Ego.