The Bhagavata Purana and Vishnu Purana narrate that Mahabali, a demon king descended from a line that included the devout Prahlada, ruled the earth with such justice and generosity that his reign surpassed even that of the gods in prosperity and popular devotion, drawing worship away from Indra and the other Vedic deities and unsettling the cosmic balance of power between gods and demons. Vishnu responded by incarnating as Vamana, a dwarf Brahmin, who approached the famously generous Mahabali during a great sacrifice and requested only as much land as he could cover in three paces.
Mahabali, despite the warnings of his guru Shukracharya, who recognized Vamana's true identity, granted the request out of his unwavering commitment to generosity and his given word. Vamana then grew to cosmic size, covering the entire earth with his first step and the heavens with his second, leaving no space for a third step until Mahabali, humbled and true to his promise, offered his own head, upon which Vishnu placed his final step, sending Mahabali down to rule the netherworld.
Moved by Mahabali's humility and unwavering commitment to his word even at the cost of his own kingdom, Vishnu granted him a boon allowing him to return once each year to visit the land and people he had once ruled justly, a visit the festival of Onam commemorates.