Bali was a demon king who was also among the most generous, just, and dharmic rulers in all the puranic histories. Through austerities and righteous rule, he had conquered the three worlds - the earth, the heavens, and the netherworlds - and the gods had been driven out.
The gods went to Vishnu for help. Vishnu incarnated as Vamana - a dwarf Brahmin boy.
Vamana came to Bali's great Ashvamedha sacrifice, where Bali had vowed to give whatever was asked of him. The demon king's guru, Shukracharya, warned him: "This is no ordinary Brahmin. Do not make this promise."
Bali overruled his guru. "I have vowed. A king's vow cannot be broken for expediency. Even if this is Vishnu himself, he has come to my sacrifice as a Brahmin, and I will give him what he asks."
Vamana asked for three paces of land. Bali agreed, smiling - a dwarf's three paces?
Vamana grew. He became cosmic. With the first step he covered the earth. With the second step he covered the heavens. He paused, looking at Bali. "Where shall I place my third step?"
Bali bowed his head and said: "On my head, Lord."
Vishnu pushed him down to the netherworlds. But he also granted Bali the boon he deserved: "You will rule the netherworlds with honor. And once a year - on Bali Pratipada - you will return to the earth you loved, and your subjects will light lamps to welcome you."