It is believed that there once lived a wise and generous asura (demon) king, Mahabali. He was highly regarded by his subjects and everybody was happy in in his kingdom.
Gods felt challenged with the growing popularity of Mahabali. They seeked help from Lord Vishnu who was worshiped by King Mahabali. Lord Vishnu took the avatar of a poor and dwarf Brahmin, called Vamana and came to the kingdom of Mahabali just after his morning prayers, when the King gave boons to the Brahmin.
The disguised Lord Vishnu asked for as much land as could be covered by his three steps. The King made a promise to do so. Suddenly, Vamana increased to a massive size. With his one step he covered the whole of the sky and with the other he covered the whole of earth. He then asked for a place to put his third step. King realised that the boy was no ordinary Brahmin and asked Vamana to to put his third step on his head.
The boy did so, pushing Mahabali in the nether world, the patala. Lord Vishnu was pleased with King Mahabali generosity and granted him a boon. Deeply attached with his people, the King said he would like to visit Kerala and his people every year. Lord Vishnu was pleased to grant the request.
It is this homecoming of King Mahabali that is celebrated as Onam every year.
Another Version of the Legend
There is another legend related to King Mahabali but with a different view point. It says, though, King Mahabali was a wise and judicious ruler, he was also very egoistic. He was a devout worshiper of Lord Vishnu and the Lord wanted to redeem his devotee of the sin.
Lord Vishnu took the avatar of a poor and dwarf Brahmin, called Vamana and asked for a piece of land from the King. The egoistic King said he may have as much land as he wanted. Vamana replied that he want only as much land as could be covered by his three steps. To this the King laughed and made a promised to do so.
The Brahmin boy increased in cosmic proportions. With his one step he covered the whole of sky and with the other, the whole of the earth. King Mahabali realised that the boy was God himself who came on a purpose and offered his head to place his third step. This pushed the king to the nether world, patala. It proved to be a blessing for the King as it released him from the cycle of life and death. This is why, Onam is celebrated by wearing new clothes. People resolve to lead a new life of honesty, piousness, love, and humility.