There are two proximate reasons and one ultimate reason as to why Jesus was crucified.
The first reason is that the Romans forbade the people they conquered, including the Jews, from executing anyone. Had that not been the case, the Jews would have stoned Jesus instead of taking Him to Pilate, falsely accusing Him of treason against Rome and demanding that He be crucified.
The second reason why Jesus was crucified is that crucifixion was Rome's preferred method of capital punishment for those found guilty of treason, so that the victims' slow and gruesome death can be seen up close by the passing masses and scare them against rebelling against Rome.
The third and the ultimate reason why Jesus was crucified is that Jesus engineered it.
Why?
Do you know which famous American once lamented, "I have spent the best years of my life giving people the lighter pleasures, helping them have a good time, and all I get is abuse, the existence of a hunted man"?
It was Al Capone. We know him as a mafia boss and criminal who killed people and ran brothels ("lighter pleasures"), but he thought he was a good person.
Our standard of morality is higher than Al Capone's, but God's standard is much higher still. In fact, the Bible says that God's standard of morality is absolute perfection and defines as "sin" anything that falls short of it, including seemingly minor offenses like jealousy (Exodus 20:17) or being angry without reason (Matthew 5:21-22). The Bible says that everyone has sinned - "All have sinned and fall short of the glory of God" (Romans 3:23) - and that the punishment mandated for sin is the death penalty: "For the wages of sin is death..." (Romans 6:23), "the soul who sins shall die" (Ezekiel 18:4). That's the bad news.
The 'Gospel,' which means, 'Good News,' is that God loves us and didn't want to wipe us out. But neither could God, who is perfectly just, simply let our sins slip by since that wouldn't have served justice. So what did He do?
He came and took our death penalty upon Himself.
If that's tricky to understand, imagine you committed and are found guilty of a crime that carries the mandatory death penalty. You rise at your sentencing and the judge sentences you to death. As you start to tremble in fear, something strange happens. The judge rises from his seat, walks down to you, removes his gown, and tells you:
"Because I am a good judge who upholds justice, I handed down the penalty required by the law, which is death. But I... am also your father, and because I love you, I will take upon myself the death penalty that you deserve, and grant you life instead of death."
That's why Jesus engineered His own death on the cross - "I am the good shepherd; and I know My sheep, and am known by My own. As the Father knows Me, even so I know the Father; and I lay down My life for the sheep. And other sheep I have which are not of this fold; them also I must bring, and they will hear My voice; and there will be one flock and one shepherd. Therefore My Father loves Me, because I lay down My life that I may take it again. No one takes it from Me, but I lay it down of Myself. I have power to lay it down, and I have power to take it again..." (John 10:14-18) - so that those who believe He did this can go to heaven: "For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life" (John 3:16). And this is why Romans 6:23 above continues: "For the wages of sin is death, but the gift of God is eternal life in Christ Jesus our Lord."
Some claim that you still need to contribute to your salvation by doing good deeds, but that's like telling a death row inmate that good conduct will free him from the death row.
However, that doesn't mean we shouldn't do good deeds. But the reason for doing them is important. We should do good deeds out of sincere gratitude for the salvation that Jesus granted us by sacrificing Himself. If we do good deeds thinking that our good deeds save us, we reject Jesus' salvation and sacrifice. We are saved not by what we do for ourselves but by what God already has done for us.
* A Roman nail imbedded in the heel bone on display at the Israel Museum in Jerusalem. The crucified victims' feet were affixed to the vertical beam of the cross by being nailed either from the sides through the heels as above or through the metatarsals from the front.