It seems kinda messy. So if I understand this right... Conan was brought on to replace Leno who wanted to quit from the Tonight Show. When Conan had been there for a while, Leno wanted to get back on the show, and they just got rid of Conan?
5 years before Leno left Tonight, he promised Conan the hosting position, saying he would go into retirement. By the time the 5 years were up, Leno had changed his mind about the retirement, and had decided to make his own primetime show, the Jay Leno Show. So far, so good.
Now, after a few months with Jay Leno's show at 10:30 and Tonight with Conan at 11:30, it became apparent that this wasn't working the way NBC wanted it to. The Jay Leno Show had abysmal ratings which were negatively impacting Conan's. NBC figured they needed to move Leno out of primetime and back into late night, so they decided they would make Leno's show a half hour long and move it to 11:30 and then move Conan to 12:05.
Conan, understandably, was not happy about the change, because NBC was messing with a franchise which for decades had gone on at 11:30. He announced that he would leave the show if NBC went through with the move, and because the network execs weren't going to change their minds, Conan did end up leaving. So Leno took The Tonight Show back, and NBC successfully kept Leno in late night by keeping him on The Tonight Show. Everybody got what they wanted, except for Conan, who was now out of a job and would start a new show on TBS some months later.