Doctor Strange made it quite clear that there was only
one way that they could beat Thanos given his 17 million-ish permutations that the experienced. Is the movie trying to imply that the sort of "worst timeline" situation that the movie ends with is actually still part of Doctor Strange's only viable win condition? It isn't entirely clear that's the case, but he did state that it was "the end game" after he gave Thanos the Time Stone rather than a "game over". Albeit, that's attempting to decipher silly comic book movie dialog, which is about as silly of a thing as the dialog itself.
I guess if we look at it this way... if Doctor Strange didn't just give him the Time Stone, Thanos would've killed Stark... and probably gotten the Time Stone eventually anyway. Stark is one of the few left alive after the "culling", which means that he is likely an important part of the plan to fix everything. So, as crazy as it seems for Strange to just give up the stone, it might make sense given what we saw and how things turned out.