Friedrich Nietzsche said this quote

It was suffering and incapacity that created all afterworlds - this, and that brief madness of bliss which is experienced only by those who suffer deeply. Weariness that wants to reach the ultimate with one leap, with one fatal leap, a poor ignorant weariness that does not want to want any more: this created all gods and afterworlds.