We all know that Doctor Strange saw 14,000,605 futures including the one where they win. Near the end of Infinity War, he gave the time stone to Thanos when he was about to kill Tony. He must have seen that Tony will be the one who will invent the time travel formula and build a second Infinity Gauntlet (of course with help of Professor Hulk) and will then snap Thanos and his army in Endgame.
That's why he saved Tony in IW. In Endgame, when Tony and Strange look at each other after Captain Marvel got punched by Thanos, we can also see Strange pointing that this is the one future where they defeat Thanos.