The allegory of the cave takes the form of a conversation between Socrates and Plato's brother Glaucon, in one of Plato's literary works, The Republic, (Volume 7).
Since Socrates never wrote anything down, we know of his teachings mainly through third party accounts. Plato had been one of Socrates' pupils, so it is possible that the allegory could be based on a real conversation that Socrates had.
Plato uses it to illustrate his concept of our ephemeral world as contrasted with his construct of the eternal world of Forms. Plato believed that humans pre-exist in an ideal world of forms before they are born into the physical world of sense perception that we find ourselves in. We cannot perceive the nature of reality through our senses, but our organs of sense perception such as when we see or hear things, nudge our memories of the divine, or ideal world of forms, and so helps us to remember the true nature of existence.
The allegory of the cave involves imagining a group of prisoners chained since birth in a cave in such a way that they can only see the cave wall in front of them. Their only visual perception is that of shadows cast against the cave wall in front of them, cast by objects on a raised walkway between them and a fire burning behind them. Only echoes of voices and sounds reach them. The prisoners mistake the shadows and echoes for reality, because that is all they know.
Socrates, (as a speaker in this dialogue from Plato's work "The Republic"), then posits what would happen if a prisoner were forcibly removed from the cave, and set free in the outside world . This seems to be an allegory for when a person is set free from illusion, and introduced to the "truth". Socrates then describes how such a person would initially feel anger and discomfort at being pulled away from his comfort zone. If he was brought out into the light, his eyes would initially be dazzled, but he would eventually start seeing things for what they really are. (Plato presumably here is referring to his ideal World of Forms, which to him is the "truth". )
Plato (talking as Socrates) then goes on to posit that such an enlightened person would grow to scorn the limited and erroneous conceptions of the people still chained to the wall in the cave, who cannot see the truth, and have to make conclusions about reality based on the shadows that they see.
Plato then has Socrates muse that the other people still in the cave, would think that the enlightened person (presumably a philosopher), has been blinded by the light and, if he (the philosopher) tries to enlighten them, they would reject this, and they might think they need to have him killed.
The latter is interesting since Socrates was indeed put on trial and sentenced to death for "corrupting the mind of the youth" with his philosophical ideas, which espoused an aristocracy rather than a democracy.
Plato explains at the end of the allegory, that he uses fire (such as the fire in the cave) and the sun as a symbol of the source of virtue, wisdom and reality, and therefore the sun is also a reference to God.
So one has to take into account that the allegory refers to more than purely to actual physical objects. Plato's "truth" encompasses the nature of abstract entities such as beauty, virtue or "Good", and the source of "Good", but also philosophical wisdom or knowledge.
If you don't have time to read much of Plato, but wanted to come into contact with some of Socrates's epistemology, book 7 of The Republic is a nice place to start.
The work is written in much easier language than one would expect from such a venerated source of much of what Western philosophical thought was built upon, so give it a go!
You can download it for free at places like Gutenberg.org.