Peter could become a compassionate apostle only after he had blundered and fallen into the sin of denying the Lord three times. It was certainly not God's perfect will for Peter to sin like that; but yet we see that God allowed it in order to do a work in Peter. It made him tender and sympathetic towards those who had failed in life.
Jesus never sinned even once, and yet He was infinitely compassionate and merciful towards sinners. But with the rest of Adam's race, that has not been the case. Those who have never fallen into gross sin usually end up being hard and unmerciful and haughty towards sinners.
When we look at the circumstances through which Peter fell into this gross sin, we see that God could have easily prevented him from even facing the temptation to deny the Lord. Yet God chose not to protect him from those moments of temptation.
In John 18:15-18, we see that John and Peter followed Jesus to the court of the high priest. Since John knew the high priest, the doorkeeper let him in. But Peter could not go in. So John came and spoke to the doorkeeper and gained admission for Peter too. That looked like a good thing at that moment. But notice the fact that Peter would not have sinned that night if John had not got Peter into that courtyard - for it was only inside there that Peter was questioned, and that he denied the Lord three times (See John 18:17,25,27).
So, we could ask the question, "Why did God allow that to happen? Why didn't He prevent Peter from gaining entry into the courtyard? Was that a mistake on God's part? No. God, in His sovereignty, permitted John to get Peter inside, so that Peter could get an education through his failure. He could not have become the leader of the apostles and the leading evangelist of the early church without having completed this course in his education.
Satan had his agents ready to tempt Peter, but he had to get God's permission to do that. But Jesus was praying for Peter that his faith would not fail in that moment of utter failure (Lk.22:31,32) ; and Jesus' prayer was answered. Peter came out of that experience a broken, compassionate man. Never again in his life would he be able to denounce sinners with harshness. Every time he was tempted to do that, he would remember his own failure and tone down his denunciation.
God can make the very worst things that ever happened in your life to work for your very best, if you have faith. During the seven weeks before Pentecost, Peter may have wished many times that John had not gotten permission for him to enter the courtyard that fateful night, so that he would not have denied the Lord. But then, he would not have been broken either, and he would have been unfit to preach the gospel to sinners on the day of Pentecost.
We know that Peter still preached against sin, for he writes in his letter about following in Jesus' steps "who did no sin", and of "ceasing from sin" (1 Pet.2:2,22; 4:1,2). But now, he preached with compassion. This was why he was given the privilege to open the door of the gospel to the Jews on the day of Pentecost, and also to the Gentiles in the house of Cornelius. God could have used James or John in either of those instances. But he didn't. He used Peter - the one who had failed miserably - for he could speak with greater compassion to wayward sinners than those others.
David was another one like Peter. Once when he avoided going to the battlefield through laziness, he slipped up badly and fell into sin - a sin that became like a black mark against him for the rest of his life and for centuries thereafter (2 Sam.11:1-5). The Holy Spirit records, "David did what was right in the sight of the Lord, and had not turned aside from anything that He commanded him all the days of his life, except in the case of Uriah the Hittite." (1 Kings 15:5). Yet God used David's failure to break him and to make him write Psalm 51 - a portion of inspired Scripture that has blessed millions for many centuries, more than any other writing of David's. David could never have written that psalm if he had fallen into a lesser sin. His failure had to be great and deep and known publicly, so that he might be thoroughly humbled and broken. He was a broken man for the rest of his life. And Jesus calls Himself the Son of David!!
SI Moderator - Greg Gordon