In Spider-Man: No Way Home, Tobey Maguire and Andrew Garfield returned as the previous big-screen versions (or should that be Variants?) of Peter Parker. We learned they had been pulled into the Marvel Cinematic Universe along with their respective villains, albeit from the present rather than the past.
Ned Leeds inadvertently discovered the two alternate reality Spider-Men while he and MJ were looking for their Peter, but that wasn't always how their introduction was going to play out.
Talking to Variety, Spider-Man: No Way Home writers Chris McKenna and Erik Sommers revealed that they didn't even know if Maguire and Garfield would be part of the cast while writing the screenplay. Instead, they would only get sporadic updates from Marvel Studios and Sony Pictures about how talks were going. Once they were locked in, it was time to figure out how to bring them into the MCU, but it wasn't originally Ned who managed to track them down with his magic hands.
"They are brought by a Marvel character going, ‘Here are the saving graces and they’re going to help you through this,'" said McKenna, refusing to reveal who that was. "It was just more of a deus ex machina." Could it have been Madame Web? That might explain why he wouldn't name this ally.
As for the decision to have Ned find the other Peters, the writer adds: "It was a beam of light in darkness. It was such a gift, particularly at that point in the writing process, to be writing for those two characters. It the darkest part of the year, the darkest part of production, the darkest part of the story development, and it was like, 'Oh! Now we get Tobey and Andrew.'"
It sounds like they didn't know that would be the case until last December (Spider-Man: No Way Home started shooting October 2020). We can all agree the end result was spectacular, though, and the scribes definitely managed to nail the reintroduction of both Maguire and Garfield's Spidey Variants.