This took place to fulfill what Jesus had said about the kind of death he was going to die.
References for John 18:32
Pilate then went back inside the palace, summoned Jesus and asked him, “Are you the king of the Jews?”
References for John 18:33
“Is that your own idea,” Jesus asked, “or did others talk to you about me?”
“Am I a Jew?” Pilate replied. “Your own people and chief priests handed you over to me. What is it you have done?”
Jesus said, “My kingdom is not of this world. If it were, my servants would fight to prevent my arrest by the Jewish leaders. But now my kingdom is from another place.”
References for John 18:36
“You are a king, then!” said Pilate. Jesus answered, “You say that I am a king. In fact, the reason I was born and came into the world is to testify to the truth. Everyone on the side of truth listens to me.”
References for John 18:37
“What is truth?” retorted Pilate. With this he went out again to the Jews gathered there and said, “I find no basis for a charge against him.
References for John 18:38
But it is your custom for me to release to you one prisoner at the time of the Passover. Do you want me to release ‘the king of the Jews’?”
They shouted back, “No, not him! Give us Barabbas!” Now Barabbas had taken part in an uprising.
References for John 18:40