"Once upon a time" is a stock phrase that has been used in some form since at least 1380 in storytelling in the English language, and seems to have become a widely accepted convention for opening oral narratives by around 1600. These stories often then end with "... and they all lived happily ever after", or, originally, "happily until their deaths."

It is particularly apparent in fairytales for younger children, where it is almost always the opening line of a tale. It was commonly used in the original translations of the stories of Hans Christian Andersen, or the Brothers Grimm as a translation for the German es war einmal (literally "it was once").

The phrase is also frequently used in oral storytelling, such as retellings of myths, fables, and folklore._Wikipedia