The escape of Socrates is planned by his friends, particularly his wealthy friend Crito, In the dialogue "Arrival of the Ship" Crito lays upon Socrates his plans of smuggling him out of jail and taking him away to live in anonymity. When Socrates refuses sternly, he makes Crito quite upset. Not only is Greek society already expecting that Crito's leverage and money WILL take their beloved rebel out of jail, but doing so would make Crito even more popular. Besides, who would refuse this offer?
Socrates did. It is all because of principle. First, likes 44-45 show that Socrates was a bit scared for the safety of his friends in trying this endeavor, however, this was not his only fear.
In line 46c he talks about his respect for the principles which he follows. Namely, that one injustice done to him does not merit that he has to commit another act of injustice to the system. Two wrongs do not equal one right. Moreover, his job is to teach about righteousness. How could he continue his testimony if he has failed to abide by it. Even more, would not he be acting like those who wronged him by also wronging the system?
However, line 48d tells the most salient reason:
The only question which remains to be considered is, whether we do rightly either in escaping or in suffering others to aid in our escape.
Using the word "rightly" means that Socrates is not speaking lightly. To be "good" is to lead an honorable life. To stand by your principles and suffer the consequences of your beliefs is the honorable thing to do. In Socrates' mind, it only makes sense for someone who lives staunchly by what he believes to die for it as well. That is the sense of martyrdom that Socrates is willing to offer to his cause.
The first principle in Socrates views of righteousness are that
neither injury nor retaliation nor warding off evil by evil is ever right.
Therefore, his ideas, the slight fear of the danger of his friends but, most importantly, Socrates' inherent passion for his principle of righteousness is what specifically made him unable to break with his beliefs and, as a result, he refused to escape.