In Matt. 26:69-75 (also Luke 22:55-62 and John 18:17-18, 25-27) the apostle Peter denied Jesus and lied about knowing Him. So why did he do this? The answer is simple. He was afraid. Of what was he afraid? Most probably he was afraid of joining Jesus in His trial before the Sanhedrin, which he knew was probably going to end in Jesus' death. Remember, Jesus had been threatened by the Jewish leadership many times before (Matt. 12:14; John 8:59; 10:31; 11:8), and undoubtedly Peter knew of this. So, if Peter had identified himself with Jesus, Peter was most probably afraid he would join Him in His fate.
Matthew 26:69–75, "Now Peter was sitting outside in the courtyard, and a servant-girl came to him and said, “You too were with Jesus the Galilean.” 70 But he denied it before them all, saying, “I do not know what you are talking about.” 71 When he had gone out to the gateway, another servant-girl saw him and said to those who were there, “This man was with Jesus of Nazareth.” 72 And again he denied it with an oath, “I do not know the man.” 73 A little later the bystanders came up and said to Peter, “Surely you too are one of them; for even the way you talk gives you away.” 74 Then he began to curse and swear, “I do not know the man!” And immediately a rooster crowed. 75 And Peter remembered the word which Jesus had said, “Before a rooster crows, you will deny Me three times.” And he went out and wept bitterly."
After the rooster crowed for the third time, Peter realized his sin, and it caused him to weep. Would we have done any better? Remember, Peter was just as much a man as anyone else. He was subject to the same frailties and weaknesses that any of us would be subject. Furthermore, though many would say they would never deny Jesus, we never know what we will actually do until we are in the situation.