The first person you have to beat is your teammate. It is a truth universally acknowledged in the paddock. After all, they are on the same bike as you, with the same support, so the only difference between your results and theirs is down to ability - in theory at least. Beat your teammate, and your team will prioritize you over them when it comes to contract renewal time, will pay you more money, will send more resources your way. If you're in a factory team, the engineers will listen more carefully to you, and more likely to follow the direction of development you set out.
Teams use this same philosophy to motivate their riders. They encourage internal competition, hoping the two riders will push one another on to greater heights, to risk more for better results. Trying to win a race is motivation enough, but adding the frisson of showing up your teammate adds that little bit extra, the icing on the cake. And reward enough should a rider fall short of winning. So far does this internal competition go that for most teams, the order in which rider quotes appear in the press release is determined by who is ahead in the championship, or who finished ahead during practice, qualifying, or the race.