Dasaratha was a king with three wives and only daughters. In order for the king to receive sons he had to perform a sacred sacrifice for the gods.
Meanwhile with the gods, Brahma was having a problem with Ravana who was causing havoc among mortals and other gods and mortals, but the gods, mortals, demons, or demigods couldn't do anything because Brahma promised Ravana's safety. Brahma is now asking for Visnu's help. Visnu is the sustainer of the sustainer of the universe.
Visnu the sustainer of the universe, will you please help me? I promised Ravana safety from gods, demigods, and demons, but I did not promise Ravana safety from the humans. Will you do the honors and go down to Earth as a human to destroy the evil of Ravana?
Yes, I will go down as one of Dasaratha's sons who has been continuously been making gracious sacrifices for sons to us. I will be Rama the son of Dasaratha, destined for the throne.
I Visnu, am going to grant you four sons, Dasaratha.