Tony Stark was on the ground.

He was injured.

He was in pain.

Fighting Thanos was hard.

Peter Parker saw him from above. He realized that if he failed to intervene, his mentor would inevitably die. And Peter wasn't about to let that happen.

As he swung down and flew between Tony and the overgrown eggplant, Peter suddenly remembered a time when he was younger. He had, thanks to chance and maybe even fate, seen Iron Man fight firsthand when he was eight years old. He could remember it so clearly... he had put his hand up, his iron man mask partially blocking his vision, knowing deep down he couldn't do anything but wanting so badly to try anyway. He always wanted to at least try. That much was his responsibility, or so he believed. This belief had carried through the years and translated into his impetus for publicly displaying his superpowers, for becoming Spider-Man.
He had to try.
He had to help.
He had to do something.

And that's why Peter knew he had to do something to help the man who had done so much for him. Even though he knew he was no match for the giant hairy grape, he would do whatever he could to save Tony Stark or die trying.

Peter's webs brought him right in front of Thanos, but before he could do anything, he was snatched aggressively from the air. He could vaguely hear Tony shouting his name, but it didn't register in Peter's brain. Nothing did. He didn't know what was happening, but suddenly his world went dark.