Mahabali was a demon king (Asura) and was the grandson of Prahalad. He was religious and also a good king. With his power and intelligence, he took over all the three worlds (Lokas), ie. Swarg Loka (heaven), Patal Loka(hell) and earth(Dharti Lok). But all the Devtas were not happy and they took help from Lord Vishnu to get back their Swarg Lok (heaven). Lord Vishnu took the avatar of a brahmin and asked King Bali for three steps of land in the donation. When Bali agreed to give three steps of land. The brahmin became enormously tall and covered all the three Lokas in two steps only. For the last step, Bali offered himself and Lord Vishnu put his third step on his head. But because of Mahabali and Prahalad devotion towards the Lord Vishnu and their good deeds, he was sent to heaven and was also awarded with immortality and was allowed to visit his kingdom once a year.
The hidden reason behind Mahabali being immortal is to restore dharma after Kaliyuga because even though being an Asura he was religious and devotee of God.
Secret scroll of Samajashastra: This book discusses Samajashastra. It included rules for the evolution of societies and the means of foretelling their decline.” - Bali