There’s a lot of decisions the heroes could’ve made differently in Avengers: Infinity War that might’ve changed the course of events significantly. Doctor Strange could’ve withheld the Time Stone from Thanos, Star-Lord could’ve kept his anger in control a moment longer, Thor could’ve gone for the Mad Titan’s head instead of his chest, etc.
Maybe the simplest one, though, is that Spider-Man could’ve just stayed at home and not got himself caught up in an outer space adventure which ended with his tragic death. On the audio commentary track for Infinity War, co-director Joe Russo laments Peter’s decision to leap out of the school bus at the first sign of trouble instead of playing it safe, saying:
“Peter inserts his way into the story in a way that’s going to have a very tragic ending for him. He should have stayed on the bus.”
On the one hand, Russo’s right about that. Peter definitely would’ve had a less stressful day if he’d just gone to school. On the other, though, presumably he still would’ve been affected by Thanos’ snap wherever he was in the universe. So, instead of dying in Tony’s arms, he could’ve passed away with Aunt May instead. And, seeing as the Russos have previously told us that May survived the Snap, this would’ve been pretty heartbreaking for her.
We imagine there’s a version of the timeline out there in which Peter did stay on the bus, and Doctor Strange viewed it when he browsed through all the different ones in Avengers: Infinity War. Fans believe that, as dire as things are, the timeline’s currently on track to be the only one where the heroes win, so maybe Peter doing the brave thing actually played its own small part in making this happen?