According to many theologians and mental health researchers, one of the main comforts that people obtain from their religious faith is the assurance that life will not end at their death. They believe that it will continue in some form forever. Another reasons for some people's belief in an afterlife might be the desire for justice. But this does not necessarily work out in practice. Many good people suffer in poverty and with disease.
Many evil people lead rewarding, rich, and long lives.
Many religions offer a belief in the afterlife that includes a resolution to the justice problem. The scales of justice will finally be balanced. Their beliefs at the instant of their death. Their behavior during their entire lifetime. The presence of any unforgiven sins committed before death.