This Buddhist story is a Jataka tale from about 400 BC. In the story, the Indian boddhisatva Vessantara wanted to give up everything for Buddhism. He gave up his kingdom and all his money and lived with his wife and children in the forest.
But in a village not far away, there was trouble. A mean old Brahmin man, Jujaka, married a young pretty girl. At first she was a good wife, but then the other girls beat her up for being a goody-goody, so she nagged him to get slaves to fetch water from the village well for her. Jujaka set off to look for slaves, and he found Vessantara and his kids (Maddi was away picking fruit). He asked Vessantara for his two kids, to be his slaves, and Vessantara gave them up, too!
Jujaka started to drag the kids away, hitting them with sticks and cursing them. The kids screamed for help. Vessantara got upset and almost shot Jujaka with his bow and arrow, but at the last minute he got control of himself and remembered that he was a Buddhist and didn’t care about anything but the Way. So he let Jujaka drag his crying kids away.
Just then Maddi came home. You’d think she’d be upset that he sold the kids, but no, she was proud that he was such a good Buddhist. The god Indra came and tested Vessantara some more, to see if he would also give his wife away. Sure, Vessantara was totally willing to give Maddi away too. But by now the gods had enough of this, and they gave everything back: the wife, the kids, the kingdom, and they all lived happily ever after.
Is this basically the Hindu story of the Ramayana rewritten for Buddhists? Is it related to the Bible story of Job? It might also be related to the earlier story of Gilgamesh, who also loses a friend and curses the gods, or to the story of Achilles and Patroclos. All of these stories are about loss and grief, but also about how hard it is to know when to act and when to let things happen: that’s also at the root of Taoism.