According to the gospels, it was customary for the Romans to release a Jewish prisoner during the Passover festival. The Roman governor Pontius Pilate tried to use this custom as an excuse to release Jesus. But a crowd in the courtyard demanded that a prisoner named Barabbas be freed instead, and Pilate eventually gave in to the pressure. Thus Barabbas was released, and Jesus was crucified.
In books and movies, Barabbas is usually depicted as an evil criminal. But he may have actually been a freedom fighter in the Jewish resistance to the Romans. Evidence for this can be found at Mark 15:7, which says that he was in prison because he had taken part in a recent uprising. In fact, some biblical scholars think that he was an important rebel leader. If so, this would explain why the crowd shouted for his release, because any leader in the fight against the hated Romans would be very popular with the common people.
But Jesus was also very popular with the common people. When he entered Jerusalem on Palm Sunday, he was greeted by large excited crowds. Many people believed that he was the long-awaited Messiah, who with God's help would overthrow all oppressive rulers and establish a new eternal Kingdom of God.
But if Jesus and Barabbas were both very popular, why did the crowd call for Jesus to be crucified and Barabbas to be released? The likely explanation is that the crowd was dominated by employees of the Jewish religious authorities. Their servants and henchmen would have been in the courtyard, and probably composed a significant part of the gathering there. Also, because Jesus was arrested late at night and brought before Pilate early the next morning, most of his followers probably didn't know where he was, or what was happening to him. And his closest followers had apparently gone into hiding out of fear of arrest.
Thus the Jewish leaders could have told their servants and henchmen to shout for Barabbas to be released, and the rest of the crowd could have then joined in. This explanation is supported by Mark 15:11, which says that the "chief priests stirred up the crowd to have Pilate release Barabbas instead." But why did the Jewish leaders want Jesus to die instead of Barabbas? The answer is that many of the common people believed that Jesus was the Messiah, and this made him a threat to their authority.
The so-called "mystery of Barabbas" refers to some puzzling similarities between the released prisoner and Jesus himself. The most striking similarity concerns their names. Some ancient Syriac copies of Matthew, and a few other ancient sources, call the freed prisoner "Jesus bar Abbas". The name Barabbas can be obtained from this by dropping the name "Jesus" and changing "bar Abbas" to "Barabbas". Furthermore, the phrase "bar Abbas" can be translated as "son of the Father", which could possibly be applied to Jesus himself, since he sometimes used the word "Abba" (father) in referring to God.
From this evidence, many scholars have concluded that Barabbas' original name was "Jesus bar Abbas". Other evidence indicates that this name was intentionally altered by later Christian writers. One well-documented case involves the scholar Origen, who reportedly promoted the change for reverential reasons, because he didn't want the name "Jesus" to be associated with a criminal.
Another similarity between the two men relates to their possible roles as rebel leaders. The gospel of Mark says that Barabbas had been imprisoned for taking part in a revolt, and his popularity with the crowd suggests that he had been one of its leaders. But from the viewpoint of the Romans, Jesus could have also appeared to be a rebel leader. Many people were calling him the Messiah, a title which implied that he would overthrow the existing government. He had a large number of followers, many of whom might be easily swayed into taking part in a revolt. In fact, his earlier attack on the temple merchants could be regarded as a "mini-revolt".
Thus, both men may have had the same name, and both of them could have appeared to be rebel leaders, at least from the Romans' viewpoint. These similarities are known as the "mystery of Barabbas". Some people think that the similarities are too close to be accidental and have looked for another way to explain them. According to one radical theory, in the original story Jesus himself was the imprisoned rebel leader, and Barabbas is an invented "fictional duplicate" inserted into the story to play that role instead. The motive for such a change would be to cover up the fact that Jesus had tried to organize a revolt against the Romans and was crucified as a result.
But this theory is mostly speculation, and its supporters have to resort to questionable arguments to explain the details. For these reasons, most scholars are unconvinced. In fact, Jesus was a common name in ancient Palestine, and uprisings against the Romans took place quite frequently. Therefore it shouldn't be surprising that a rebel leader with the same name as Jesus would happen to be in Roman custody on the day of the crucifixion.
Note: The gospels don't say what Barabbas did after he was released. But other ancient sources do preserve some traditions about him. According to one tradition, on the day he was released he went to Golgotha and watched Jesus die on the cross. Some sources also say that he was later killed while taking part in another revolt against the Romans.