He said this to indicate that he would die by being lifted up on the cross.
(This was to fulfill the words of Jesus when he predicted the manner of death that he would die.)
(Jesus said this to Peter as a prophecy of what kind of death he would die, for the glory of God.) And then he said, “Peter, follow me!”