In ancient times, the lantern festival was a time to worship Taiyi, the God of Heaven. It is said that Taiyi controlled the destiny of the human world and was helped by sixteen dragons. These dragons brought drought, storms famine or pestilence.
Qin shi-huang, the first Emperor to unite China, ordered splendid ceremonies be held every year to please or appease Tayi. The people of China and the Emperors that followed believed that these ceremonies pleased Taiyi and helped bring good weather and good health to the people of China.
A later Emperor named Wudi proclaimed that this celebration was one of China's most important and for this reason it would last all night.
The Yuanxiao Story: Long ago in ancient China there lived a palace maid named Yuan xiao, a kind and clever girl who was locked up in the palace of her Emperor Wu Di all year round. This made her sad and homesick. Luckily she found a friend in a minister called Dongfang Shuo.
Shuo made up a story for the emperor which helped Yuanxiao see her family again. He said that the God of Fire has been ordered to set the city of Changan on fire on the 15th day of the first month of the lunar year. Let us make him think the city is already on fire by setting off fire crackers and hanging red lanterns all over the city.
In order to do this, everyone, even the palace maids, will have to help and take part in a great lantern show. Now Shuo knew that the God of Fire loved to watch a good fire show and liked the dumplings made by Yuanxiao just as much. "Let Yuanxiao give her dumplings to the fire god," said Shuo to his emperor, "for that will please him and save the city from fire."
The Emperor ordered all the people of Changan to spend the whole night setting off firecrackers and playing with lanterns. It was a very rare thing for girls to go out at night and meet boys of their same age. Yuanxiao was able to leave the palace and meet her family for a fine and happy time and the next year it all happened again!
The Emperor Wu Di enjoyed himself so much that he ordered even more red lanterns for the next year. (Red was the color to scare away evil spirits and bad luck.) So, on the very same day this next year, Yuanxiao made her dumplings again and saw her family.
In other versions, the emperor had done something to displease the god and others worked to trick the god. On that night, when the god saw the lights from the city, he believed that the city had been set on fire.