Plato used this allegory in his masterpiece "The Republic" (Politeia in greek) to explain his dialectical theory of knowledge, that is
based on the Theory of Forms, and in a dualistic conception of the
world -There are two realms, the Visible World (Kósmos Aisthetós) and the Intelligible Realm, where Forms are (Kósmos Noetós)-.
Plato's gnoseological theory states that knowledge undergoes an ascendant and descendant process, divided in several phases, Doxa (Opinion) and Episteme (Science or Knowledge). Inside the first one there are two more phases, Eikasía (The uptake of images of the objects in the visible world) and Pistis (the assumption about the properties of the things in the visible world). Furthermore, Episteme is divided in Dianoia (The knowledge of the mathematical Forms) and Noesis (pure intellection of the Forms). Then the process descends to become aware of the Form's hierarchy and conformation.
P.S.: The text above may be a little bit cryptic for some people (taking into account that my English is not perfect and that I didn't explain some concepts), if so, I apologize.
On the first comment there are more pictures with explanation.