Once Indra, the king of gods, asked Agni, the fire god, and Vayu, the wind god, to go and kill all the demons. Agni and Vayu were very powerful and killed most of the demons but the rest hid in the ocean. So they returned and told Indra that they could not kill the rest of the demons.
Indra was very angry. He ordered Agni and Vayu "Even if you have to churn the ocean, you must get those demons out and kill them."
Agni and vayu said that they didn't want to churn the ocean as there were other creatures living in it and they would also have to suffer because of the demons.
Indra was not convinced and said, "The ocean has given shelter to the wicked and should suffer for that. But you two are trying to evade your duty by disobeying me. I curse you to be born as humans on earth." Thereafter, Agni was born as Sage Agastya while Vayu took birth as Sage Vashishtha.