It's been nearly four years since Tony Stark snapped Thanos into oblivion in the epic Avengers: Endgame, sacrificing himself to save the universe. It was heartbreaking to fans, but his death had been all but predicted as far back as 2008.
The first Iron Man introduced Tony as a warmonger who created weapons of mass destruction. When he saw what his weapons did in the wrong hands, he decided to create his most powerful weapon yet – the Iron Man suit – and bring "peace in our time."
His legacy was that of death and destruction, and he told his business-partner-turned-supervillain Obadiah Stane, "I don't want a body count to be my legacy." In every movie since, he took increasingly larger steps toward his sacrifice.
In 2012's Avengers, he proved Captain America wrong by making the "sacrifice play" – carrying a nuclear warhead into a wormhole. In 2015's Age of Ultron, he told Cap that they could fight low-level bad guys as much as they want, but the otherworldly threat in his visions was the "endgame."
Since his imprisonment at the hand of terrorists in Iron Man, all he cared about was his legacy. Not in the typical egotistical manner; he wanted to leave behind a legacy of good. A legacy that his eventual daughter could be proud of.
When matched up against Thanos, he made – to quote Yinsen in Iron Man – "The last act of defiance by the great Tony Stark!"
He stood against the Mad Titan, now with a daughter and more to lose than ever before, and let himself die so trillions can live.
Not bad for a legacy.
The first Iron Man also featured Tony's prediction of Pepper's reaction to his sacrifice, one that was completely spot-on.
At the end of Iron Man, he told Pepper that – as a proper superhero – he should have a girlfriend who'd constantly worry about him but proud of the man he'd become. She would be "wildly conflicted." That's exactly what happened with Pepper in Endgame; she wanted him to stay safe with their new daughter in a devastated universe but urged him to fight to bring back what they'd lost.
There were several other callbacks that, after re-watching, the entire franchise, predicted his ultimate sacrifice. They all are part of his evolving legacy and the steady development of his desire for good – a desire perfectly encapsulated in 2016's Civil War:
"I never stopped, because the truth is I don't want to stop."
And it all began with the existential question of legacy while locked in a desert cave.