Or they might be lying. If you deny Committing the crime and, unknown to you, your friend also denies it, the case might be hard to prove. In the ensuing plea bargain, both your sentences will be very light. If you confess, and your friend does likewise, then the effort the State must expend to solve the crime is small. In exchange, you both will be given a fairly light sentence, although not so light as if you both had asserted your innocence.
Someone is very vulnerable to a kind of double cross.
So, if you and your friend both plead innocent, you both escape the worst. But each must be sure of the other. Then, if your friend pleads innocent while you plead guilty, well, too bad for him, and you might get off scot- free. When you think it through, you realize that, whatever your friend does, you're better off confessing. Maddeningly, the same holds true for your friend.