Doctor Strange was a practical man and there were probably many versions (millions, maybe), where Thanos was defeated and Tony didn’t have to die.
As we know, Doctor Strange said that he has seen all the 14,000,604 outcomes of their fight against Thanos and apart from one, they lose in every other plausible future.
It directly states that there was indeed only one winning scenario for the Avengers and it needed Iron Man’s sacrifice to come true.
Thus the theory postulates that when Doctor Strange searched through the outcomes of the different ways they try to defeat Thanos, there were many that resulted in the Avenger’s victory.