One legend tells us that it was a time to worship Taiyi, the God of Heaven in ancient times. The belief was that the God of Heaven controlled the destiny of the human world. He had sixteen dragons at his beck and call and he decided when to inflict drought,storms, fafmine or pestilence upon human beings.Beginning with Qinshihuang, the first emperor to unite the country, all subsequent emperors ordered splendid ceremonies each year. The emperor would ask Taiyi to bring favorable weather and good health to him and his people. Emperor Wudi of the Han Dynasty directed special attention to this event. In 104 BC,he proclaimed it one of the most important celebrations and the ceremony would last throughout the night.
Another legend associates the Lantern Festival with Taoism. Tianguan is the Taoist god responsible for good fortune. His birthday falls on the 15th day of the first lunar month. It is said that Tianguan likes all types of entertainment. So followers prepare various kinds of activities during which they pray for good fortune.
The third story about the origin of the festival boes like this. Buddhism first entered China during the reign of Emperor Mingdi of the Eastern Han Dynasty. That was in the first century. However, it did not exert any great influence among the Chinese people. one day, Emperor Mingdi had a dream about a gold man in his palace. At the very moment when he was about to ask the mysterious figure who he was, the gold man suddenly rose to the sky and disappeared in the west. The next day, Emperor Mingdi sent a scholar to India on a pilgrimage to locate Buddhist scriptures. After joumeying thousands of miles,the scholar finally returned with the scriptures. Emperor Mingdi ordered that a temple be built to house a statue of Buddha and serve as a repository for the scriptures. Followers believe that the power of Buddha can dispel darkness.
So Emperor Mingdi ordered his subjects to display lighted lanterns during what was to become the Lantern Festival.
Source : http://www.chinavoc.com/festivals/lantern.htm