This story was narrated by Rishi Lomasha to Yudhishthira during the latter's pilgrimage (Mahabharata, Vana Parva, Tirthayatra Parva)
"One cannot enjoy or suffer for another person's acts." - Lord Dharma to Somaka
Somaka
There was a virtuous king Somaka by name. He had one hundred wives, all suitably matched to their husband. He took great care, but could not succeed in getting a single son from any one of them, and a long time elapsed during which he continued a sonless man. Once, when he had become old, and was trying every means to have a son, a son was born to him, Jantu by name, out of that century of women. All the mothers used to sit surrounding their son and every one giving him such objects as might conduce to his enjoyment and pleasure. It came to pass that one day an ant stung the boy at his hip. The boy screamed loudly on account of the pain caused by the sting. Forthwith the mothers were exceedingly distressed to see how the child had been stung by the ant. They stood around him and set up cries. Thus there arose a tumultuous noise. That scream of pain suddenly reached the ears of the sovereign of the earth, when he was seated in the midst of his ministers, with the family priest at his side. Then the king sent for information as to what it was about. The royal usher explained to him precisely what the matter was with reference to his son. Somaka got up together with his ministers and hastened towards the female apartments. On coming there, he soothed his son. Having done so and coming out from the female apartments, the king sat with his family priest and ministers.
Somaka then spoke thus, “Fie on having only a single son! I had rather be a sonless man. Considering how constantly liable to disease are all organized beings, to have an only son is but a trouble. O Brahmana! With the view that I might have many sons born to me, this century of wives has been wedded by me, after inspection, and after I had satisfied myself that they would prove suitable to me. But issue they have none. Having tried every means, and put forth great efforts, they have borne this single son, Jantu. What grief can be greater than this? I am grown old in years and so are my wives too. And yet this only son is like the breath of their nostrils, and so he is to me also. But is there any ceremony, by celebrating which one may get a hundred sons? Tell me whether it is great or small, and easy or difficult to perform.”
The family priest said, “There is a ceremony by virtue of which a man may get a century of sons. If you are able to perform it, O Somaka! then I shall explain it to you.”
Somaka said, “Whether it be a good or an evil deed, the ceremony by which a hundred sons may be born, may be taken by you as already performed. Let your blessed self explain it to me.”
The family priest thereupon said, “O king! Let me set on foot a sacrifice and you must sacrifice your son, Jantu in it. Then on no distant date, a century of handsome sons will be born to you. When Jantu's fat will be put into the fire as an offering to the gods, the mothers will take a smell of that smoke, and bring forth a number of sons, valourous and strong. Jantu also will once more be born as a self-begotten son of yours in that very mother; and on his back there will appear a mark of gold.”
Somaka said, “O Brahmana! Whatever is to be performed, do precisely as it may be necessary. As I am desirous of having a number of sons, I shall do all that may be prescribed by you."
Then the priest officiated in the sacrifice in which Jantu was offered as the victim. But the mothers is in pity forcibly snatched the son and took him away. They cried, “We are undone!” They were smitten with torturing grief and they caught hold of Jantu by his right hand, and wept in a piteous way. But the officiating priest held the boy by the right hand and pulled him. Like female ospreys they screamed in agony! But the priest dragged the son, killed him and made a burnt offering of his fat in the proper form. While the fat was being made an offering of, the agonised mothers smelt its smell, and of a sudden fell to the ground and swooned away. Then all those lovely women became with child. When ten months had passed, a full century of sons was born to Somaka begotten on all those women. Jantu became the eldest and was born of his former mother and he became the most beloved to the women, not so were their own sons. On his back there was that mark of gold and of that century of sons, he was also superior in merit.
Then that family priest of Somaka departed this life as also Somaka after a certain time. Now he beheld that the priest was being grilled in a terrible hell. Thereupon he questioned him, “Why are you, O Brahmana! being grilled in this hell?" Then the family priest exceedingly scorched with fire, spoke to him saying, “This is the outcome of my having officiated in that sacrifice of yours.” Hearing this, the saintly king thus spoke to the god who metes out punishments to departed souls, “I shall enter here. Set free my officiating priest; this revered man is being grilled by hell-fire on my account only.”
Dharmaraja thereat answered thus, “One cannot enjoy or suffer for another person's acts. These are the fruits of your acts; see it here.”
Somaka said, “Without this Brahmana here, I desire not go to the blessed regions. My desire is to dwell in company with this very man, either in the abode of the gods, or in hell, for, O Dharmaraja! my deed is identical with what has been done by him and the fruit of our virtuous or evil deed must be the same for both of us.”
Dharmaraja said, “O king! If this is your wish, then taste with him the fruit of that act, for the same period that he must do. After that you shall go to the blessed regions.”
The king did all that exactly in the way prescribed to him. When his sins were worked off, he was set free together with the priest. Fond of the priest as he was, he won all those blessings to which he had entitled himself by his meritorious acts and shared everything with the family priest.