All four Gospels include accounts of Jesus' prediction of Peter's denial of Him (Matthew 26:34, Mark 14:30, Luke 22:34, John 13:38). When Jesus told Peter that, before the rooster crowed, he would deny Him three times, Peter was adamant. He basically told Jesus, "No way, Lord! Maybe some of the others will deny you, but me? Not only will I never deny you, but I'll also fight for you, even if it means I have to die for you."
Of course, just hours later, what did Peter do? He denied that he even knew Jesus, not once but three times, just as Jesus said he would. Then, when the rooster crowed after Peter's third denial, he remembered Jesus' words. Peter was devastated (Matthew 26:75). I'm sure that, over the next three days, Jesus' words and his own actions haunted Peter's thoughts continually. His heart and his spirit were surely broken. I can imagine him thinking, "How can I ever put this behind me? I disowned the Lord!"
Although Scripture doesn't tell us this, my guess is that what happened that night continued to haunt Peter even after Jesus rose from the grave. I'm sure that Peter was overjoyed that Jesus was alive but he probably wondered if Jesus could ever forgive him for what he had done. Maybe that's why Peter decided to go out and fish again not long after Jesus had appeared to the disciples (John 21:3). He probably thought that he was of no use to the Lord anymore, so he might as well go back to being a fisherman.
But Jesus had other plans. He wasn't done with Peter. After a fishing experience (John 21:3-11) similar to the one when Peter first met Jesus (Matthew 5:1-11), Jesus shared a fish breakfast with the disciples. After they finished eating, Jesus turned to talk to Peter. Jesus asked Peter if he loved Him. Peter replied that, yes, he did. Jesus asked the question a second time, and Peter once again responded that he did love Him. Then, Jesus asked a third time. Peter was hurt and said, "Lord, you know all things. You know that I love You!" (John 21:15-17)
Of course, Peter was right. Jesus did know the answer before he even spoke it. So, why did He ask the same question three times? Jesus was giving Peter the opportunity to be restored after his denial. Jesus had already forgiven Peter even before Peter had denied Him but He knew Peter's heart and spirit were broken because of his denial. I believe Jesus intentionally asked the question three times so that Peter could forgive himself and put his triple denial behind him so that his heart and spirit to be restored.
That is such a great example of the great love and mercy Jesus has, not only for Peter, but also for all of us. It shows the tremendous grace that He extends to us. But, the best part of this story, to me, are the words that Jesus says to Peter each time Peter affirms his love for Him:
"Feed my lambs."
"Take care of my sheep."
"Feed my sheep."
Jesus was telling Peter that, not only was he forgiven, but that He also still placed His trust in Peter and was entrusting him with His flock. What a vote of confidence!