When Cell self-destructs himself and kills Goku in the process, Goku thought he got rid of Cell for good. But because Cell has Saiyan DNA in him, he has the Saiyan ability to gain tremendous power after being beaten to near-death.
When Cell blew himself up, a singe cell of him remained, which was enough for him to completely regenerate. He also learns Goku's Instant Transmission technique in the process. Those two factors allowed Cell to return to Earth, surpassing his Perfect form, becoming Super Perfect Cell.
Gohan with Goku's encouragement, and Vegeta's assistance destroys Cell. Then the Buu saga