A Model of Non-physical Punishment(Masechet Berachot Daf נה. Perek 9 Siman 38)
(condensed from Ein Ayah, Berachot 9:38)
Gemara: Rav Chisda said: A bad dream is harsher than lashes, as the pasuk says, “Hashem made that they should have fear of Him” (Kohelet 3:14), and Rabba bar bar Chana explained that this is referring to a bad dream.
Ein Ayah: Affliction of the spirit is much greater and more troubling than affliction of the body. Therefore, a bad dream, in which Divinely-inspired fear impacts on the power of imagination of the spirit, is more powerful than physical pain.
This power itself is exactly what engenders the positive part of a bad dream. This is because the fear of punishment, which is important for the furtherance of the world, has to be able to be perceived in a way that man can absorb it. In order to fully fear punishment, one has to know of the idea that the soul lives on after the death of the body, at which time it will receive its reward and punishment. However, man, who is steeped in the material world, has trouble picturing punishment of the soul. For that purpose, a nightmare comes to cause a person poignant spiritual pain and fear of a type that gives him some idea what he may feel in punishment after death. In this way, he is less likely to be tricked into believing that he will escape payment for his sins when he is dead. He will recognize that even without a body and its pain, one is capable of suffering in a spiritual manner, through fear, pain, and embarrassment that affect the spirit. This will give the dreamer a broader perspective of the proper fear of Hashem and His punishment.