Allegory is a device where the writer uses a narrative to describe the characters and plot of the story to give hints about the abstract ideas or theme of the whole story. In an allegorical story, characters or objects represent more than their literal meaning.
For example, many children's stories use animals as characters to present abstract ideas like morality, strength, or kindness. Allegory can also be used to depict political or more complex ideas. For example, during WWII, many short stories had animal characters to portray political views or people.
Example 1: The moral story about the race of Mr. Rabbit and Mr. Turtle. In the story, the slow and steady turtle wins, while the quick rabbit loses because of his arrogance. In this allegorical story, the writer presents the character of the turtle as steady, calm, and good, whereas the rabbit's character presents arrogance, ego, and bad.
Example 2: In 'Animal farm' by George Orwell, the formation of a dystopian society represents the rise of Stalin and the Soviet Union. The characters of pigs represent figures such as Stalin, Trotsky, and Molotov. This story's characters depict a political view rather than an abstract idea.