Plato's allegory of the cave is perhaps the best-known of his many metaphors, allegories, and myths.
The allegory is told and interpreted at the beginning of Book VII of The Republic (514a-520a). The allegory is probably best presented as a story, and then interpreted--as Plato himself does.

The allegory

Imagine prisoners chained since childhood deep inside a cave. Not only are their limbs immobilized by the chains, their heads are as well so that their eyes are fixed on a wall. Behind the prisoners is an enormous fire, and between the fire and the prisoners there is a raised way, along which men carry shapes of various animals, plants, and other things. The shapes cast shadows on the wall, which occupy the prisoners' attention. Also, when one of the shape-carriers speaks, an echo against the wall causes the prisoners to believe that the words come from the shadows. The prisoners engage in what appears to us to be a game--naming the shapes as they come by. This, however, is the only reality that they know, even though they are seeing merely shadows of images.

Suppose a prisoner is released and compelled to stand up and turn around. His eyes will be blinded by the firelight, and the shapes passing will appear less real than their shadows. Similarly, if he is dragged up out of the cave into the sunlight, his eyes will be so blinded that he will not be able to see anything. At first, he will be able to see darker shapes such as shadows, and only later brighter and brighter objects. The last object he would be able to see is the sun, which, in time, he would learn to see as that

this it is that provides the seasons and the courses of the year and presides over all things in the visible region, and is in some sort the cause of all these things that they had seen. (The Republic bk. VII, 516b-c; trans. Paul Shorey)
This part of the allegory, incidentally, closely matches Plato's metaphor of the sun which occurs near the end of The Republic Book VI.

Once thus enlightened, so to speak, the freed prisoner would no doubt want to return to the cave to free "his fellow bondsmen." The problem however is that they would not want to be freed: descending back into the cave would require that the freed prisoner's eyes adjust again, and for a time, he would be inferior at the ludicrous process of identifying shapes on the wall. This would make his fellow prisoners murderous toward anyone who attempted to free them.

The interpretation

Not content with mere suggestion, Plato interprets the allegory (beginning at 517b): "This image then [the allegory of the cave] we must apply as a whole to all that has been said"--i.e., it can be used to interpret the preceding several pages, which concern the metaphor of the sun and the divided line. In particular, Plato likens "the region revealed through sight," i.e., the ordinary objects we see around us

to the habitation of the prison, and the light of the fire in it to the power of the sun. And if you assume the ascent and the contemplation of the things above is the soul's ascension to the intelligible region, you will not miss my surmise... . [M]y dream as it appears to me is that in the region of the known the last thing to be seen and hardly seen is the idea of good, and that when seen it must needs point us to the conclusion that this is indeed the cause for all things of all that is right and beautiful, giving birth in the visible world to light, and the author of light and itself in the intelligible world being the authentic source of truth and reason... . (517b-c)
The brilliant sun outside the cave represents the Form of the Good, and this passage among others can easily give the impression that Plato regarded this as a creative god. Ordinarily we are held captive, viewing mere shadows of particular shapes that are themselves not even the genuine article--which can only be found "outside the cave," in an intelligible world of forms known by reason, not (relatively "dim") perception.

Moreover, after "returning from divine contemplations to the petty miseries of men," one is apt to cut "a sorry figure" if,

while still blinking through the gloom, and before he has become sufficiently accustomed to the environing darkness, he is compelled in courtrooms or elsewhere to contend about the shadows of justice or the images that cast the shadows and to wrangle in debate about the notions of these things in the minds of those who have never seen justice itself? (517d-e)
Plato could, perhaps, be thinking (or subtly reminding the reader) of the trial of Socrates here.

It might appear strange that, while acknowledging the political ineptness of one "returning from divine contemplations," Plato has all the while been describing the ideal state, ruled by philosopher-kings, a qualification of which is that they are in regular intercourse with the Form of the Good.