Therefore when they were gathered together, Pilate said unto them, Whom will ye that I release unto you? Barabbas, or Jesus which is called Christ?
Note 1 at Mt 27:17: Pilate knew that Jesus was innocent, but he was looking for some diplomatic way of releasing Jesus that would not cost him any loss of popularity with the Jewish leaders. This was why he sent Jesus to Herod. He was hoping that Herod would pass judgment on Jesus and save him the trouble.
When that scheme failed, he then drew on an old custom of releasing a prisoner to them at the feast. He gave the people a choice between Jesus, who he knew was innocent, and Barabbas, who was a murderer. Pilate thought that the crowd would certainly choose Jesus. However, through the insistence of the chief priests and scribes, the people chose Barabbas as the one who should be released.
Pilate was out of ideas as to how to let Jesus go yet save face with the Jews, so he condemned Jesus to death. Pilate violated what he knew to be true in his heart because of a fear of man (Pr 29:25) and what he thought they might do to him. Without the chief priests' cooperation, he ran the risk of unrest among the Jews and possible punishment by Caesar for failure to govern well.
As it turned out, Pilate was deposed by Tiberius Caesar anyway just a few years later and died in exile in Gaul in A.D. 41. Pilate gained a five-year extension of his troubled rule at the most and damned his soul in the process. What people compromise to keep, they'll lose. Sin is never worth the price (Ro 6:23).