While most of Xavier's intentions are good, they often have dramatic consequences that branch out well past mutant kind. So, while removing the corruption from his dear friend's head, sounded like a great plan, it spawned one of the deadliest events in Marvel history.
While trying to "cleanse" Magneto, the professor inadvertently created a new entity as the negative aspects of these two Omega Level Mutants merged inside Xavier's head. The X-Men realise they're out of their depths, but luckily for them, back up arrived just in time.
Unfortunately, their relief would be short lived as, even with The Avengers, the Fantastic Four and any other superhero they could find, there was no winning this fight.
After a huge explosion separated Banner from the Hulk, Onslaught's physical form was beaten, but the entity lived on. The only thing left that the heroes of Earth could do was sacrifice themselves in order to destroy the entity, so that's what they did.
that, when a human merged with the entity, it was possible to destroy
it, by destroying the humans within. Every non-mutant hero sacrificed
themselves to Onslaught, while the X-Men were left to destroy it and all
the heroes inside.