The Second Doctor broke the laws of time by interfering in another planet's problems, so the Time Lords punished him by forcing him to regenerate. This was how he became the Third Doctor.
According to many fans (starting with Paul Cornell, who co-wrote The Discontinuity Guide and has written episodes of the new series), between the 2nd Doctor's sentencing and his forced regeneration, he secretly worked for the Celestial Intervention Agency, a semi-secret branch of the Time Lord government. But, if so, we don't know whether the CIA got tired of dealing with him, or he rebelled against them, and either way, the forced regeneration and exile ultimately happened just as we saw on TV. (See Season 6b for more information.)
For more information, see What caused each Doctor to regenerate?