Yama is, of course, Death, the ruler of the lower world.
The messengers of Death are three: Old Age, Sickness, and Mortality.
The earliest form of the fable is that found in the Anguttara-Nikâya, iii. 35, pp. 138-142 (ed. Morris for the Pali Text Society), where it is used by Buddha to point a moral. The following is an abstract of the Pâli:
When an evil-liver in word, deed, and thought, says Buddha, disappeared from this world, and underwent re-birth in hell, he was brought before Yama, who sharply interrogated and questioned him. "Did you see Death's first messenger?" he asked. "I did not," replied the sinner. "What! did you never see an old man or woman bent down with age, palsied, wrinkled, and grey-headed?" "I have seen such a one," answered the man. "Did not you, a man of mature age and intelligence, take note that you were subject to old age, and would not escape it; and did you thereupon determine to conduct yourself well in word, deed, and thought?" "Through remissness, I did not take note of this," replied the man. Then Yama questioned the culprit as to Death's second messenger (the sight of a man or woman suffering from sickness and disease, or bedridden); and lastly, as to the third messenger—a dead man or woman in various stages of corruption. In each case the offender had to confess that, through negligence, he had not applied the sickness and mortality of his fellow-creatures to his own case. For his remissness he was condemned by Yama to the severest tortures, and handed over to hell's warders to undergo the sentence uttered against him.
The account of Buddha's "drives" previous to the "great renunciation" points the same moral lesson—namely, that old age, sickness, and death remind us that we are mortal (see Anguttara-Nikâya, iii. 38, 39). As the story of Buddha's life was well known very early in Europe through the popular versions of Balaam and Josaphat, it was probably through this channel that the legend of "Death's Messenger" found its way into the fable literature of Europe. It does not occur in the Jâtaka book, the Panca-Tantra, or the Kalilag and Damnag literature.