The origin of the Service of the Dead (Panakhida) is as follows:
St. Macarius of Alexandra once inquired from the angels who accompanied him an explanation of the Church's custom to celebrate the third, ninth, and fortieth days after death by religious services. And the Angel told him - "When on the third day the body is taken to the Temple, the Soul of the dead receiveth from his/her Guardian Angel relief from the grief which he/she feeleth at the parting from the body. This he/she receiveth because of the oblation and praise which are offered for him/her in God's Church whence there ariseth in him/her a blessed hope. For during the space of two days the Soul is permitted to wander at will over the earth, with the Angels which accompany it. Therefore, the Soul, since it loveth its body, sometimes hovereth around the house in which it parted from the body; sometimes around the coffin wherein its body hath been placed: and thus it passeth those days like a bird which seeketh for itself a nesting place. But the beneficient Soul wandereth through those places where it was wont to perform deeds of righteouness.
"On the third day He who rose again from the dead commandeth that every Soul, in imitation of His own ressurection, shall be brought to heaven, that it may do reverence to the God of all. Wherefore, the Church hath the blessed custom of celebrating oblation and prayers on the third day for the Soul."
"After the Soul hath done reverence to God, He ordereth that it shall be shown the varied and fair abodes of the Saints and the beauty of Paradise. All these things the Soul vieweth during six days, marvelling and glorifying God, the Creator of all. And when the Soul hath beheld all these things, it is changed, and forgeteth all the sorrow which it felt in the body. But if it be guilty of sins, then, at the sight of the delights of the Saints, it beginneth to wail, and to reproach itself, saying "Woe is me! How vainly did I pass my time in the world! Engrossed in the satisfacton of my desires, I passed the greater part of my life in heedlessness, and obeyed not God as I ought, that I, also, might be vouchsafed these graces and glories. Woe is me poor wretch!' After having thus viewed all the joys of the Just for the space of six days, the Angels lead the Soul again to do reverence to God. Therefore the Church doth well, in that she celebrateth service and oblation for the Soul on the ninth day.
"After its second reverenceto God, the Master of all commandeth that the Soul be conducted to Hell; and the divers of torments of the ungodly, which cause the souls of sinners that find themselves therein to groan continually, and to gnash their teeth. Through these various places of torment the Soul is borne during thirty days, trembling lest it also be condemned to imprisonment therein.
"On the forieth day the Soul is again taken to do reverence to God: and then the Judge determineth the fitting place of of its incarceration, according to its deeds to await the final judgement. Thus the Church doth rightly in making mention, upon the forieth day, of the baptised dead."
OrthoMan