According to Merriam-Webster dictionary, allegory is defined as “the expression by means of symbolic fictional figures and actions of truths or generalizations about human existence.”
The origins of the word stem from the Greek words “allos” which means “other” and “goria” which means “speaking“, putting the two together creates “allegoria“. This is later adopted by Old French, creating the word “allegorie“.
Allegory is oftentimes confused with metaphor, but they are not the same thing. An allegory is a story/narrative in which objects such as setting, characters, and/or other thing is a symbol and has a meaning. A metaphor is the comparison of two things that are not necessarily related that creates imagery.
Allegory employs symbolism. Metaphor employs imagery.
A literary example of an allegory is Faerie Queen by Edmund Spenser. The protagonists each symbolize virtues such as holiness and wisdom, while the antagonists symbolize vices such as wickedness and evil. Some more examples can be found on Literary.com.
A literary example of a metaphor can be namely found in poetry, but a literature example could be William Shakespeare’s Shall I Compare Thee to a Summer’s Day, where the title is a metaphor; comparing the protagonist to a summer day (insinuating beauty and pleasingness). Some more examples of metaphors can be found on Literary.com.
Here’s an infograph from Pediaa.com that can help drive the point home: