Shichi-Go-San is said to have originated in the Heian Period amongst court nobles who would celebrate the passage of their children into middle childhood. The ages 3, 5 and 7 are consistent with East Asian numerology, which claims that odd numbers are lucky. The practice was set to the fifteenth of the month during the Kamakura Period.
Over time, this tradition passed to the samurai class who added a number of rituals. Children—who up until the age of three were required by custom to have shaven heads—were allowed to grow out their hair. Boys of age five could wear hakama for the first time, while girls of age seven replaced the simple cords they used to tie their kimono with the traditional obi. By the Meiji Period, the practice was adopted amongst commoners as well, and included the modern ritual of visiting a shrine to drive out evil spirits and wish for a long healthy life.