So you've contracted a nasty case of that new strain of flu, you just lost your job in fine foods, and your highest-ranked node got nuked with extreme prejudice. And you're wondering, what happened, Fate, Kismet, Wyrd? My karma's kosher, my tithes are paid, I rub the Buddha's belly whenever I eat at Kanki. What transpired that I must suffer? Who's mad at me? Well, obviously-
One of your dead ancestors just got sued in the underworld by another stiff. And you haven't provided for the defense attorney.
Or so the Taoist priesthood of China explained to laypeople during the bureaucratization of state and personal ritual practice during the early medieval period, around 400-500 CE, in what was known as the Celestial Master tradition. The movement, thought, and action of the deities above, according to the Confucian-Taoist culture of the time, mirrored exactly the workings of the government of the nation under the Emperor, all the way down to the way commoners and nobility were treated under the machinations of the complex Chinese judicial system. Under this system and the social codes that surrounded it, one was morally responsible for one's kin and their actions, and could be held judicially responsible as well. When this understanding was extended to religion, it was easy enough to form a coherent theory of why the living suffered in a seemingly random fashion in such an orderly universe as was presented in the theology of the Celestial Masters.
Heaven and the underworld had both prisons and courts in the writings of Taoist priests. References are made in Taoist petitions to the gods to "the Twenty-Four Prisons of Tai" - a belief maintained throughout the medieval period that the sacred mountain of Tai in the northeast was the seat of the administration of the dead. In such locations and their regional offices, such as those of the Three Officials of Heaven, Earth, and Water, the dead could place accusations against those who injured them, just like the living on earth. Illness and family misfortune were the repercussions of such suits - the word for "investigation" used in such cases was the same word, kao, that was used to describe the simultaneous questioning and torture used to gain reliable testimony from multiple witnesses. Once an ancestor was in the dock, those relatives still living would suffer from guizhu, or "demonic vapors", which would cause both illness and misfortune through the harassment of evil spirits. It would be up to a priest to recognize these illnesses for what they were: reaction to sepulchral plaints, or "lawsuits of the tomb".
Example (from Bokenkamp's Early Daoist Scriptures): A shadowy mystic named Yang Xi was the spiritual adviser for the Xu family, particularly for Xu Mi and his son Hui. When Xu Mi's wife, Tao Kedou, died, the family not soon after began suffering illness. Yang Xi's otherworldy informants reported that the illness was the result of a sepulchral plaint involving Xu Mi's deceased uncle, Xu Chao. Lord Mao the Youngest, one of the three Mao brothers for whom Mao Shan was named, declared a few months later that Xu Chao had, in fact, violently murdered two people, who had now brought their accusation before the Water Official, the most feared of the three. Tao Kedou had been compelled to return to her tomb to select one of her children to die in retribution for this uncle's transgressions.
The Taoist priests relied on sepulchral plaints with the utmost frequently to explain such misfortune, and of course, simultaneously offered the cure. The idea of prayer as synonymous with filing papers with a celestial official was already well-established, and by the sixth century, a Taoist priest behaved in such situations far more like counsel going through judicial pomp and circumstance than as a transcendent link to an unknowable Divine. The priest discovered the plaint by correspondence with the correct heavenly bureaus and filed an answering petition in the name of the family in a religious ceremony that had heavy, and heavily modern, legalistic overtones. The petitions to respond to sepulchral plaints were formulaic, with spaces for names to be filled in, and the ritual for their delivery involved invocations to the correct offices in Heaven, exactly as messages were required to be sent to the correct imperial offices. The same words were used for sending petitions to heaven as were for petitions to earthly rulers - "zou zhang". Priests even carried a hu, the same type of tablet brought by an official entering the court of his ruler. In the sepulchral plaint and the rituals that tended to it, the priest was an official figure right down to the details - showing the intimate connection between Chinese beliefs in earthly life and those as related to that which came after, a tradition which stretched back even to Mesopotamia and Egypt.