I think it's useful to realize this isn't a binary question, in almost any sense:
1. As you said, the amount of luck you are born with makes a huge difference in how much you "deserve" the money, for some definition of deserve.
2. Part of this luck includes things like your intelligence, ability to work, energy levels, etc, risk tolerance, all of which is (partially) genetic, and contributes to the whole "he put in lots of work" part of the equation. So even for that, you can't really give him sole "credit".
3. And obviously, the society he lives in paved the way for lots of this success, in so many different ways (not least of which is creating the internet in the first place).
4. Then again, we don't have to say "well he did the hard work, so he should reap 100% of the benefits". In fact, we don't say that - we tax him quite a bit, so that not 100% of his money goes to his descendants, rather part of it goes to maintaining society, helping poorer people, etc.
5. Worth mentioning that "put in the hard work" is one framing of what he did - but I'd personally prefer framing it as "created a huge amount of value for other people, worth so much money, and he got some percentage of that.
6. Of course other people might disagree with point 5, or at least want to point out that part of the value created was possibly do to exploitation (I mostly disagree with this framing - not saying there was or wasn't exploitation, but I think at a minimum you have to acknowledge that Amazon did provide a lot of value to a lot of people, way more than the insanely large amount of money that Bezos has).
I mention all the above, because I think it's useful to reframe things from moralistic question of "what someone deserves" in an abstract sense, to the much more practically relevant question of "someone created some amount of value, got to extract some (smaller) part of that value, how much of what they extracted do we want to take and spread around society, versus how much do we want them to keep?". That is usually the actual question facing voters/lawmakers, and has lots of ramifications, but is much more concrete, and more easily lends itself to optimization.