I give talks at conferences for the same reason I write blog posts. A talk or a post gives me a reason to get my thinking straight about something. There's nothing like trying to explain something to force you to figure out how it really works and identify the places where you are hand-waving over gaps in your understanding.
Fame/ego _sounds_ like a nice side-effect of this activity, especially when you succumb to survival bias and look at people who have been writing for a while or speaking for a while.
But to get here, I had to give some talks that were soundly (and rightly) criticized. That can be humiliating, and more than once I have vowed never to give another talk. Many others followed through and gave one talk, or maybe two, and then never gave another.
Same for blogging. Today I'm supposedly a good writer. But 3/4 of my posts generate crickets. Writing is a terrible way to try to build your ego, it's either criticism or the resounding impression that nobody cares about you and your writing.
Sure, I guess some people want to be famous and have people applaud their talk and are willing to plug away at it to get there for that reason, but in all honestly, if fame is what you seek, writing code is a far easier path to that fame.
---
Summary:
To get to the point where you get your ego stroked, you have to endure a lot of your ego being totally destroyed. Most people don't make it past that, therefore if we are to postulate a reason for giving a talk, "ego" is not a good reason for most people, because most people never get that ego boost.