As Vishnu's cursed doorkeeper
In the Bhagavata Purana, Ravana and his brother, Kumbhakarna, were said to be reincarnations of Jaya and Vijaya, gatekeepers at Vaikuntha, the abode of Vishnu and were cursed to be born in Earth for their insolence.
These gatekeepers refused entry to the Sanatha Kumara monks—- who, because of their powers and austerity, appeared as young children. For their insolence, the monks cursed them to be expelled from Vaikuntha and to be born on Earth.
Vishnu agreed that they should be punished. They were given two choices, that they could be born seven times as normal mortals and devotees of Vishnu, or three times as powerful and strong people, but as enemies of Vishnu. Eager to be back with the Lord, they choose the latter one. Ravana and his brother Kumbhakarna were born to fulfill the curse on the second birth as enemies of Vishnu in the Treta Yuga. The curse of first birth was fulfilled by Hiranyakashipu and his brother Hiranyaksha in Satya Yuga when they were both vanquished by earlier avatars of Vishnu (Hiranyaksha by Varaha and Hiranyakashipu by Narasimha) and the curse of third birth was fulfilled by Dantavakra and Shishupala in the Dvapara Yuga when they both were slain by Krishna, the eighth avatar.