Thoughts on Socrates:

(1) I think some things in human life are constrained. To me it seems Socrates had to do what he had to do and his end had to be the way it was.

(2) It has been argued that  Socrates could have argued that not all laws are created equal. Some laws are for expedience. Some are  expressions of natural law. Some laws are unjust.

(3) Also, I should mention that Socrates was not just bothering the leading citizens of Athens, but  among his followers were people that were traitors to Athens. The court might have been aware of this.