Why was Socrates given the death penalty?
When Socrates was tried and convicted (and sentenced to death) there were two charges against him.
First, the Athenian authorities claimed that Socrates refused to worship the Greek gods. This was completely untrue -- Socrates was always diligent in performing the required rituals, even though he did not necessarily believe in them.
Second, he was charged with corrupting the youth. The basic idea here is that his questioning was turning them against the values and the political system of the city. The general reason for this was that he kept criticizing democracy. It was also in part because a couple of people who had been his students became dictators in Athens.
You can also say that he was executed because he was stubborn. At his trial, he refused to apologize or show remorse or even accept exile. In that way, he sort of forced them to kill him.