This is the backstory behind four of Vishnu's avatars: Varaha (Boar), Narasimha (Man-Lion), Rama, and Krishna.
Jaya and Vijaya were closely guarding the gates of Vaikuntha (literally, "place of eternal bliss"), the abode of Lord Vishnu and Goddess Lakshmi. They were astonished to see four young boys approaching the gate.
"Stop right there and identify yourselves," Jaya commanded.
"We are the Four Kumaras," the boys cried in unison.
"I am Sanaka," said the first boy.
"I am Sanandana," said the second.
"I am Sanatana," said the third.
"And I am Sanatkumara," said the fourth.
"Why are you here? What do you want?" asked Vijaya.
"We want to see Lord Vishnu," said one of the boys.
"You cannot see Lord Vishnu now, as he is resting," said Jaya.
"Lord Vishnu never rests," said another boy. "If he did, the universe would cease to function."
"We have come a long way to see Lord Vishnu," said the third boy. "Please let us in."
"No," said Vijaya firmly.
"You have misused your position as gatekeepers of Vaikuntha and denied us entry," said the fourth boy. "We hereby curse you: you will be born on Earth multiple times."
Just then, Vishnu emerged from his chamber and arrived at the gate after hearing the commotion.
"These boys just cursed us for doing our jobs," Jaya and Vijaya complained to Vishnu.
"Your job is not to become a barrier between my devotees and me," Vishnu said. "You have committed a grave error and deserve to be punished. But since you have served me loyally for so long, I will lighten your punishment. You could spend three lives on Earth as demons who will oppose me, or you could spend seven lives on Earth as my devotees. Which choice do you prefer?"
Jaya and Vijaya couldn't bear to spend too much time away from Lord Vishnu, so they chose the shorter option: three lives on Earth as demons who would be slain by the Lord himself.
Thus, in the Satya era, Jaya and Vijaya were born as the demons Hiranyakashipu and Hiranyaksha, respectively. In the Treta era, they were born as the demons Ravana and Kumbhakarna. In the Dvapara era, they were born as the demons Shishupala and Dantavakra. Each time, they were slain by an avatar of Vishnu, finally freeing them from the Kumaras' curse.