Christ taught every time He spoke. Christ was God with us in a flesh body. He was teaching any and all that, even on our best day, how easy it is to puff ourselves up and take pride in what is not ours from the beginning.
The mind Peter exhibited when Christ called him out was just like that of Satan. It was a lesson, that few ever take to heart.
Peter, for his part, was exhorting Jesus not to go to Jerusalem (out of love for Jesus), fearing danger for Jesus.
Jesus knew he would be doing Gods will, going to his execution, and not his own (human) will nor Peters (which he even addressed in his own human way in the Garden of Gethsemani, Lord, take this cup from me. No Answer. Follow on by Jesus, Thy will be done.).