As Rishyashringa was conducting King Dashratha's ritual, the devas begged Vishnu to take birth as Dasharatha's son.
"As Dasharatha's son, O Vishnu, you can put a stop to Ravana's cruelty," said Indra. "He torments the whole earth! You are the only one who can save us."
"Ravana won protection from devas and danavas, from nagas, yakshas, gandharvas, and so on," Brahma explained. "But in his arrogance, he did not request protection from humans."
"I will do as you ask," Vishnu said to the gods. "Prince Rama of Ayodhya will be my avatar; I agree to be born as Dasharatha's son."
Inspired by: The Ramayana (Bala Kanda).
Notes: The backstory of how Ravana got that boon of protection comes in the Uttara Kanda of the Ramayana, a book added on at the end which gives backstories for many of the main characters.