The full plot of Spider-Man: No Way Home follows a broken spell, a gathering of villains from other universes and a final spell that erases Peter from everyone's memory.
After Peter's identity is made public, he, MJ, Ned Leeds and May Parker are arrested, and a legal fight clears them of the charges. Their college applications are rejected because of the notoriety. Peter asks Doctor Strange to make the world forget him as Spider-Man, but his interruptions corrupt the spell, and it opens the multiverse.
Villains from other realities who know Spider-Man's identity arrive: Dr. Otto Octavius, Max Dillon, Flint Marko, Curt Connors and Norman Osborn / Green Goblin. Peter Parker (Tom Holland) wants to cure them rather than send them back to certain deaths. To do that, he steals the spell and traps Strange in the Mirror Dimension, a decision that turns a rescue mission into a direct clash with the Sorcerer Supreme.
The cost comes quickly. The Green Goblin side of Norman Osborn retakes control and turns the villains against Peter. In the fight the Goblin fatally wounds May Parker, who tells Peter that with great power comes great responsibility. It is the line that anchors the character's whole history, and here it lands as a farewell.
Two other Spider-Men from other universes then arrive, Peter Parker (Andrew Garfield) and Peter Parker (Tobey Maguire), and they help Peter Parker (Tom Holland) cure the villains at the Statue of Liberty. Ned Leeds frees Strange, and the Goblin is cured as well. The set piece works as a team effort between three versions of the same hero, which is the film's central selling point.
With the villains cured, Peter asks Strange to cast a different spell, one that makes everyone forget him, so the multiverse stays safe and the visitors can go home. Everyone in the world forgets Peter, including MJ and Ned Leeds. Weeks later he looks in on them but decides not to approach them. He visits May's grave, then starts again in a new suit as a solo hero.