The phrase "know thyself" (Greek: γνῶθι σεαυτόν) was a maxim actually inscribed near the entrance to the temple of Apollo at Delphi. Although Plato has Socrates discuss it in several dialogues, he was not the originator of the phrase; instead, it was a well known maxim in his period.
The first important element of Socrates' appropriation of the phrase has to do with his self-positioning with respect both the sophists and natural philosophers of his period. At his trial, he was accused both of speculating about natural philosophy and of being a sophist. Part of how Plato refutes this is by showing him mainly to be interested in ethics and in helping people develop self-knowledge as opposed to speculating about religion or physics.
The next aspect of the phrase is its relationship to "Socratic ignorance." Rather than claiming to have knowledge, as did the sophists, Socrates claimed to be wise only in knowing that he was ignorant. He sees knowing the limits of one's knowledge and admitting to ignorance as the first step to wisdom.
In the middle dialogues, Socrates advances the theory of recollection. According to this theory, the soul had perfect knowledge of the "forms" and the divine before it descended into the body. Thus the best way to obtain knowledge of these things is not by trusting our senses but by looking inside ourselves to recover these memories of the knowledge our soul had before we were born.