An ancient legend ascribes the occasion to an interesting story about the 16 year old son of King Hima. His horoscope predicted his death by snake-bite on the fourth day of his marriage. On that particular day, his newly-wed wife did not allow him to sleep. She laid out all her ornaments and lots of gold and silver coins in a heap at the entrance of the sleeping chamber and lit lamps all over the place. Then she narrated stories and sang songs to keep her husband from falling asleep.
When Yama, the god of Death, arrived at the prince’s doorstep in the guise of a Serpent, his eyes were dazzled and blinded by the brilliance of the lamps and the jewelry. Yam could not enter the Prince's chamber, so he climbed on top of the heap of gold coins and sat there the entire night listening to the stories and songs. In the morning, he silently went away.
Thus, the young prince was saved from the clutches of death by the cleverness of his new bride, and the day came to be celebrated as Dhanteras. It is also know as ‘Yamadeepdaan’ as the ladies of the house light earthen lamps or ‘deep’ and these are kept burning throughout the night glorifying Yama, the god of Death.