Bruno Bettelheim’s “The Uses of Enchantment: The Meaning and Importance of Fairy Tales” was a groundbreaking book in this area. He demonstrates how fairy tales were used to help children of different ages cope with their baffling emotions and anxieties. “Beauty and the Beast”, for example, was aimed at older girls who in a few years might be married to a much older man and obliged to leave her parents and live in his house. Other stories were aimed at much younger kids.
He does touch on why certain numbers are significant in fairy tales: Three is important to the child because it is the trinity of the family: mom and dad with the child at the center. Seven crops up a lot because it is the number of planets that could be seen with the naked eye (this is why the number 7 is considered lucky).
A ground breaking book in this area...one apparently largely plagiarized from a 1963 book by Julius Heuscher, “A Psychiatric Study of Fairy Tales: Their Origin, Meaning and Usefulness”, at least according to Bettleheim’s biographer Richard Pollak in his book “The Creation of Dr. B”.