Jesus said this to show by what kind of death Peter would bring glory to God. After saying this, Jesus told Peter, "Follow me!"
Peter turned around and saw the disciple whom Jesus loved. That disciple was following them. He was the one who leaned against Jesus' chest at the supper and asked, "Lord, who is going to betray you?"
When Peter saw him, he asked Jesus, "Lord, what about him?"
Jesus said to Peter, "If I want him to live until I come again, how does that concern you? Follow me!"
So a rumor that that disciple wouldn't die spread among Jesus' followers. But Jesus didn't say that he wouldn't die. What Jesus said was, "If I want him to live until I come again, how does that concern you?"
This disciple was an eyewitness of these things and wrote them down. We know that what he says is true.
Jesus also did many other things. If every one of them were written down, I suppose the world wouldn't have enough room for the books that would be written.