SPOILER alert for Avengers: Infinity War and Avengers: Endgame.
Interestingly enough, before Doctor Strange (Benedict Cumberbatch) gave us the "Endgame" title, Tony Stark had mentioned the word "endgame" in Avengers: Age of Ultron. Strange and Stark shared a loaded endgame moment in Infinity War when Doctor Strange revealed he went forward in time to view alternate futures, to see all the possible outcomes of the coming conflict. He told Star-Lord he saw 14,000,605 futures.
Tony Stark asked, "How many do we win?" Doctor Strange gave Tony a long look, then replied, "One." At the time, fans didn't know that the "one" necessitated Tony Stark's death. But Strange knew.
Avengers: Endgame screenwriters Christopher Markus and Stephen McFeely have been addressing fan theories about the movie, including the speculation that there was more than one way to defeat Thanos. As THR told the writers, fans have posited there were multiple ways the team could've "won" the conflict, but Doctor Strange picked the scenario where the Infinity Stones would also be destroyed, thus ensuring they couldn't return for use again.
The writers shot down that theory as not true. There was only one way end to this conflict, period, and it meant the endgame for Iron Man:
The only way this works is if Tony dies. If you go back and watch Infinity War, when [Strange] says 'one,' Benedict … is just choked on emotion. Now that you know the end, go back and watch that moment. He means, 'You're going to have to die, Tony.'
Watch that Infinity War scene again here in this clip, if you can, to relive that moment with all of its added meaning after Endgame:
Doctor Strange could've spoiled the ending of Avengers: Endgame right then and there, and instead he only gave hints. We're in the endgame now.
Tony Stark checked in with Doctor Strange during Endgame, asking if this was it, if they were in the reality where everyone survives. Doctor Strange's cryptic reply -- "If I tell you, it won’t happen" -- was a big hint to Tony's role. Tony would have to sacrifice his life, to miss out on his daughter's future. But after meeting up with his father in the past, it seemed like he knew he wanted to be the kind of man who put others before himself.