This was how original Spider-man Peter Parker was able to retake control of his body back from Superior Spider-man Otto Octavius.
After realizing he failed New York and he couldn’t defeat the Green Goblin and his army on his own, Otto admits to himself, and to Peter’s consciousness, that Peter was really the superior hero of the two. It must have been hard for Otto to admit the painful truth that he knows he’s not smart enough, and that’s he’s flawed, which explains his overcompensation. In contrast, he adds that Peter’s guilt stems from the fact that he knows he’s smarter that’s why he engages on self-sabotage. But when the going gets tough, Peter pushes away any doubt and does the right thing.
With this in mind, Otto voluntarily wipes his own memories from Peter’s body so he could go and stop Green Goblin, and rescue Anna Marie Marconi, Otto’s love interest.
From – Superior Spider-man #30