Ravana is a rakshasa king, and the Ramayana is careful to establish that he earned his power rather than simply having it. He is a brahmin’s son, a scholar of the Vedas, an accomplished musician, and an ascetic of terrifying persistence: he performs austerities for ten thousand years, cutting off one of his heads at the end of each thousand and offering it into the fire, until Brahma stops him at the tenth and grants what he asks. What he asks for is invulnerability to gods, demons, spirits and every supernatural being — and, holding humans and animals in contempt, he does not think to include them.
The gods come to Brahma to complain about what they have created.
भगवंस्त्वत्प्रसादेन रावणो नाम राक्षसः । सर्वान् नो बाधते वीर्याच्छासितुं तं न शक्नुमः ॥१-१५-६॥ त्वया तस्मै वरो दत्तः प्रीतेन भगवंस्तदा । मानयन्तश्च तं नित्यं सर्वं तस्य क्षमामहे ॥१-१५-७॥
“O Brahmá, mighty by thy grace, Rávan, who rules the giant race, Torments us in his senseless pride, And penance-loving saints beside. For thou well pleased in days of old Gavest the boon that makes him bold, That God nor demon e’er should kill His charmed life, for so thy will. We, honouring that high behest, Bear all his rage though sore distressed.” — Ramayana 1.15.6–7, tr. Griffith
The loophole is the plot. Vishnu agrees to be born as a man, because a man is the one thing the boon forgot, and everything that follows — Dasharatha’s childlessness, the sacrifice, the birth of Rama — is machinery for delivering a mortal capable of killing him. Ravana’s own arrogance drafts the terms of his death.
His crime, when it comes, is oddly restrained by the standards of his power. He carries Sita off, and then does not touch her, because he is under an older curse that he will die if he forces a woman who is unwilling. So he waits, and argues, and threatens, for a year, in a garden. His brother Vibhishana tells him plainly to give her back and is exiled for it; his brother Kumbhakarna tells him the war is wrong and fights it for him anyway. He is warned by everyone and persuaded by no one.
Valmiki gives him a death with full honours. Rama kills him and then instructs that his funeral rites be performed properly, saying enmity ends at death. In South and Southeast Asian retellings he is often more sympathetic still — a great king, a devotee of Shiva, a master of the vina — and in parts of India he is venerated rather than burnt in effigy. He is the wiki’s clearest case of a monster who is a monster by decision rather than by nature: everything he needed to avoid his fate was available to him, including the advice.