Socrates said it at his trial in Athens in 399 BC, according to the version of his defence written by his student Plato in the Apology (38a). He means that a life spent without questioning what you believe and how you live is not worth living — and he says it while refusing to stop questioning, even to save his life.
What it means
A life you never stop to question — your beliefs, your choices, what you think is good — is not really lived at all. Socrates is not saying such a life is worthless to others; he is saying that examining it is the thing that makes it worth having.
Where it comes from
The line comes in Socrates' second speech, after he has been found guilty, when he proposes his own penalty. He explains why he cannot simply agree to go into exile and keep quiet: doing so would mean giving up the daily conversation about virtue that he calls the greatest good for a human being.
In Jowett's 1892 translation the full sentence reads: “…and if I say again that daily to discourse about virtue, and of those other things about which you hear me examining myself and others, is the greatest good of man, and that the unexamined life is not worth living, you are still less likely to believe me.” The jury sentenced him to death.