The circumstances that led to the release of Barabbas start in Luke 22. There, Jesus is arrested and questioned by the leaders of the Jewish community. They ask him if he claims to be the Son of God. When he answers “You say that I am,” they take that to show that he is claiming that he is.
Therefore, they lead him off (in Luke 23) to the Roman governor, Pilate. Pilate sees no reason under Roman law to charge Jesus and sends him to Herod. Herod also declines to prosecute Jesus. However, the crowd of Jewish leaders and people is insistent. They feel that Jesus has committed blasphemy against their religion. Therefore, they want him dead. When Pilate says that he will release Jesus, they cry for Barabbas to be released instead. When the crowd repeatedly insists on this, Pilate gives in to them and releases Barabbas.