Note: This post contains a bunch of spoilers explaining the ins and outs of Avengers: Endgame--particularly its ending. You've been warned.
The title of Avengers: Endgame isn't just something cool--it's a clue to how Endgame connects to to Avengers: Infinity War. Specifically, the Endgame title recalls a line Doctor Strange said toward the end of Infinity War, revealing the fact that there's more to the end of the battle with Thanos than was immediately obvious. After the heroes fail to stop Thanos on Titan and he absconds from Titan with the Time Stone, Strange tells Tony Stark, "We're in the endgame now." It sounds like a weird thing to say, given that the end seems so near--Thanos now has five of six Infinity Stones, and he's about to achieve his goals.
But while it seems like the Avengers have lost, Strange acknowledges that letting him get the stones is actually a necessary part of his plan for actually beating Thanos, and there's more to the fight against the Mad Titan than just this battle. He's saying he has a plan. (Check out our Endgame review to see if the finale measures up to the setup.)
Infinity War ended with Thanos's victory and his snap, in which he used the Infinity Stones to eliminate half of all life in the universe. Among those who ceased to exist was Doctor Strange, who never got a chance to explain what his big plan was. Now that Avengers: Endgame is here, we can see what he was thinking--and why he changed his mind about allowing Thanos to get the Time Stone.
First, it's important to remember exactly what Strange said in Infinity War. Originally, his plan was to keep the Time Stone away from Thanos by any means necessary, but he was unwilling to let Tony destroy it or otherwise take it away from him--Strange was insistent that he keep the stone. After he was kidnapped by Thanos's lieutenant, Ebony Maw, and rescued by Tony and Spidey, Strange reiterated that the most important thing in the fight was the stone. He pointedly told Tony that no matter what happened, he would protect the stone, even at the cost of the lives of Tony, Peter Parker, or both.
When they reach Titan, Doctor Strange spends part of the discussion of how to take down Thanos using the Time Stone. He watches some 14 million possible timelines, and as he tells Tony, and only saw one in which the Avengers won the battle. The fight ensues with the team coming close to getting the Infinity Gauntlet away from Thanos, which could have allowed them to stop him, but they're unsuccessful. In the final moments of the fight, Thanos stabs Tony in the gut, then prepares to finish him off.
This is the moment where Strange changes things. He makes a bargain with Thanos: Spare Tony's life in exchange for the Time Stone. It's a big shift from Strange's earlier declaration that the stone was more important than anyone on the team. Strange's comment about being in the endgame comes soon after, once Thanos has departed from Wakanda. That reveals that Strange changing his mind and saving Tony services some greater agenda, more important than keeping the Time Stone away from Thanos.
We all know what happens next: Thanos wins. But Endgame reveals why Strange made the decision that he did, because Tony's survival in Infinity War is essential to everything that happens. When Scott Lang returns from the Quantum Realm, he reveals that Hank Pym's shrinking technology can make time travel possible--but it's Tony Stark who figures out how the team can travel to specific places and times, without getting lost along the way. Strange knew that the Avengers couldn't beat Thanos in a straight fight, but that they'd be able to eventually undo the snap--if Tony was still alive to help them figure out how.
Strange and Tony have another big moment during the climax of the film. As Tony is battling Thanos, trying to get the Gauntlet away from him so he can't use the Infinity Stones again, he catches Strange's eye. The pair have already had a conversation about the future; as Strange puts it, telling Tony about what was going to happen would cause it not to happen, because the knowledge would cause Tony (and potentially everyone else) to change how they would act.
In the final moments of the fight, Strange, meeting Tony's eyes, raises one finger. It calls back their earlier discussion--this is the one successful version of events, telling Tony they're on the right path. But Strange is also signaling what Tony has already realized: that it's up to Tony to defeat Thanos, and to use the Infinity Stones to do it. And Tony knows from seeing both Thanos and Hulk use the Gauntlet that it'll likely kill him.
The reality is that Strange has known this was how things had to go the whole time. He stopped Thanos from killing Tony in Infinity War because he knew that Tony had a huge role to play in the rest of the fight. Tony would be essential to helping secure time travel; he'd be necessary to get hold of the Space Stone and build the gauntlet that would allow the Avengers to use the Infinity Stones; and he'd be the one to finally defeat Thanos.
And when Strange said he couldn't tell Tony the outcome or it would change, it was because he knew that Tony still had one more role to play: He'd have to sacrifice himself to beat Thanos.
The bummer is that Strange knew all this, but in 14 million timelines, couldn't see another way forward--maybe one where Tony got to live a long and happy life with his family. But with the Marvel Cinematic Universe's big arc beginning with Iron Man and closing with Avengers: Endgame, it's pretty fitting that the key to everything would be Tony Stark, doing the very thing Steve Rogers said Tony was incapable of during their first mission together in The Avengers: sacrificing himself for the greater good.