Let's put it this way. Imagine you have every chance to become king of the hill, emperor of China, ruler of the known universe. The only thing standing between you and that is your best pal from kindergarten. And he's been a useless jerk anyway.
Would you say "screw him!" and turn on him? I'd be sorely tempted to.
Furthermore, it's not clear from the historical records whether they were truly good friends or not. It's possible that they knew each other, but whether they were friends is debatable. They did serve under He Jin, and Cao Cao did let Yuan Shao take the position of commander-in-chief of the allied forces against Dong Zhuo. But Yuan Shao was a git and didn't manage the campaign well, so it only made sense for Cao to break away and start his own business.