In his Lives and Opinions of the Eminent Philosophers, Diogenes Laertius nonchalantly tells us that Socrates was "the first to discourse on the conduct of life, and the first philosopher who was tried and put to death." Diogenes does not offer an opinion as to whether or not these two things are connected, but even if it is not his intention, he certainly raises that question.
In what way did Socrates "discourse on the conduct of life"? Socrates was concerned especially with what he called "the proper care of the soul", but it must be emphasized that for Socrates "caring for the soul" was not some special activity set apart from the rest of one's life, it is something that permeates every aspect of living one's life. In fact, more than anything else, how we care for our souls is synonymous with how we live our lives, at least in Socrates' view.
Socrates dedicated himself to discussing with his fellow Athenians how we should live, that is, how we should care for our souls. And in return they put him on trial and executed him. But "the first philosopher who was tried and put to death" did not go quietly. Socrates used his defense speech to turn the tables and put his accusers on trial. That speech is justifiably considered to be a masterpiece of soaring rhetoric. But the function of rhetoric is to win over one's audience, and this Socrates failed to do: a (narrow) majority of the jury voted to convict him.
Here is how R.E. Allen assesses the speech:
[T]he Apology is a highly peculiar masterpiece. Socrates constructs an engine of rhetoric according to a well-marked plan. But engines have a function, and the function of forensic rhetoric is to win conviction if prosecuting and win acquittal if accused. The engine Socrates constructs does not work this way at all. Far from aiming at acquittal, the speech avowedly aims at telling the truth in accordance with justice even if the truth leads to conviction. [Allen 1984, p.64]While it is true that the jury sentenced Socrates to die, Diogenes Laertius writes that "not long after" the execution, "the Athenians felt remorse." He even states that those who had brought the accusations against Socrates were banished from the city, except for one, who was himself put to death, and that the city of Athens then erected a bronze statue in Socrates' honor. [DL II.42-44]
Socrates' speech to the jury was a seamless of continuation of how he had lived his life. This is one of the things that seems to evade people who puzzle over why Socrates acted as he did at the end of his life. But all one has to do is to look carefully at what Socrates had said and done leading up to his trial, and to realize that he really meant what he had been saying all along.
"Not knowing very much about the other world, I do not think I know."
At a pivotal point in Socrates' speech he says "But perhaps someone might say: 'Are you then not ashamed, Socrates, of having followed such a pursuit, that you are now in danger of being put to death as a result?'" This is an important question to answer: if Socrates' conduct has been lawful and even admirable, why does he now find himself so widely hated? But Socrates insists that anyone who poses such an objection does not "speak well":
You are wrong if you think a man in whom there is even a little merit ought to consider danger of life or death, and not rather regard this only, when he does things, whether the things he does are right or wrong and the acts of a good or a bad man. For according to your argument all the demigods would be bad who died at Troy, including the son of Thetis, who so despised danger, in comparison with enduring any disgrace, that when his mother (and she was a goddess) said to him, as he was eager to slay Hector, something like this, I believe, “My son, if you avenge the death of your friend Patroclus and kill Hector, you yourself shall die; for straightway, after Hector, is death appointed unto you; he, when he heard this, made light of death and danger, and feared much more to live as a coward and not to avenge his friends, and said, “Straightway may I die, after doing vengeance upon the wrongdoer, that I may not stay here, jeered at beside the curved ships, a burden of the earth.”. Do you think he considered death and danger?Here is my own summary of the above:
For thus it is, men of Athens, in truth; wherever a man stations himself, thinking it is best to be there, or is stationed by his commander, there he must, as it seems to me, remain and run his risks, considering neither death nor any other thing more than disgrace.
So I should have done a terrible thing, if, when the commanders whom you chose to command me stationed me, both at Potidaea and at Amphipolis and at Delium, I remained where they stationed me, like anybody else, and ran the risk of death, but when the god gave me a station, as I believed and understood, with orders to spend my life in philosophy and in examining myself and others, then I were to desert my post through fear of death or anything else whatsoever. It would be a terrible thing, and truly one might then justly hale me into court, on the charge that I do not believe that there are gods, since I disobey the oracle and fear death and think I am wise when I am not.
For to fear death, gentlemen, is nothing else than to think one is wise when one is not; for it is thinking one knows what one does not know. For no one knows whether death be not even the greatest of all blessings to man, but they fear it as if they knew that it is the greatest of evils. And is not this the most reprehensible form of ignorance, that of thinking one knows what one does not know? Perhaps, gentlemen, in this matter also I differ from other men in this way, and if I were to say that I am wiser in anything, it would be in this, that not knowing very much about the other world, I do not think I know. But I do know that it is evil and disgraceful to do wrong and to disobey him who is better than I, whether he be god or man. So I shall never fear or avoid those things concerning which I do not know whether they are good or bad rather than those which I know are bad.
And therefore, even if you acquit me now and are not convinced by Anytus, who said that either I ought not to have been brought to trial at all, or since was brought to trial, I must certainly be put to death, adding that if I were acquitted your sons would all be utterly ruined by practicing what I teach—if you should say to me in reply to this: “Socrates, this time we will not do as Anytus says, but we will let you go, on this condition, however, that you no longer spend your time in this investigation or in philosophy, and if you are caught doing so again you shall die”; if you should let me go on this condition which I have mentioned, I should say to you, “Men of Athens, I respect and love you, but I shall obey the God rather than you, and while I live and am able to continue, I shall never give up philosophy or stop exhorting you and pointing out the truth to any one of you whom I may meet, saying in my accustomed way: “Most excellent man, are you who are a citizen of Athens, the greatest of cities and the most famous for wisdom and power, not ashamed to care for the acquisition of wealth and for reputation and honor, when you neither care nor take thought for wisdom and truth and the perfection of your soul?” And if any of you argues the point, and says he does care, I shall not let him go at once, nor shall I go away, but I shall question and examine and cross-examine him, and if I find that he does not possess virtue, but says he does, I shall rebuke him for scorning the things that are of most importance and caring more for what is of less worth.
This I shall do to whomever I meet, young and old, foreigner and citizen, but most to the citizens, inasmuch as you are more nearly related to me. For know that the god commands me to do this, and I believe that no greater good ever came to pass in the city than my service to the god. For I go about doing nothing else than urging you, young and old, not to care for your persons or your property more than for the perfection of your souls, or even so much; and I tell you that virtue does not come from money, but from virtue comes money and all other good things to man, both to the individual and to the state. If by saying these things I corrupt the youth, these things must be injurious; but if anyone asserts that I say other things than these, he says what is untrue. Therefore I say to you, men of Athens, either do as Anytus tells you, or not, and either acquit me, or not, knowing that I shall not change my conduct even if I am to die many times over."[28b-30c, Harold North Fowler translation]
(1) Socrates uses Homer's Iliad (modestly comparing himself to Achilles!) to remind his audience that courage is a basic virture of the Hellenes, and that anyone who fails to do what is right out of fear of death is a coward and a "burden of the earth".
(2) Then Socrates recounts his own military service ("at Potidaea and at Amphipolis and at Delium"), not to boast, but simply to once again remind his audience that not "remaining at one's station" even "at the risk of death" is "a terrible thing", and that if Socrates had failed to "obey the oracle" out of fear of the consequences then his fellow Athenians would be right and justified in hating him.
(3) But then Socrates subtly switches his argument. Fearing death is not only cowardly, it is presuming to know what one does not know, unless one knows what death really is (that is, what awaits us in "the other world").
(4) And now Socrates states (once again) that there is, perhaps, one way in which he truly is wiser than others: "that not knowing very much about the other world, I do not think I know."
(5) But no sooner has Socrates proclaimed that he does not know "very much" about the other world, he unconditionally asserts that the does know "that it is evil and disgraceful to do wrong and to disobey him who is better than I, whether he be God or man."
(6) At this point Socrates then renounces what we might today call "plea bargaining". He states that he does not wish to be acquitted if this entails the condition that he refrain from carrying on as he has always done. He assures the jury that if he is freed he will continue to do "as the God commands me to do", and that he would do so even if it were possible to kill him "many times over"!
[The entire text of the Apology is available online here. That is Benjamin Jowett's translation - the translation used above is by Fowler, which can be found at the Perseus website.]
The Varieties of Sceptical Thought:
 Sceptical Scepticism
 Socrates on Death
 Socrates' Advice to the Jury
 Richard Popkin
 Overview of the Trial of Socrates
 "Socrates of all mortals is the wisest"