This is a mysterious question and science is also finding its answer that what happens after death? What is an afterlife and where that soul or consciousness goes? There are different beliefs in different religions on this mystery. In Hinduism, there is the belief that the soul goes nowhere it takes another birth or you can say rebirth. It changes its body as you change your cloth. Christianity there is the belief that the soul rests in peace. In Muslims, they believe that soul goes to God.
So, there are different theories but nothing has solid proof just only assumption.
Science is finding answers that what happens after death. You know what modern science saved many lives after death also. The doctor observed that a patient died but in few minutes its consciousness back. After that these persons told was shocking. Some told they can clearly see what was happening with them and what was nursing staff doing in the operation theatre. Some see they are going somewhere and they were happier. These facts were shocking but what they told was true.
The afterlife (also referred to as life after death or the world to come) is an existence in which the essential part of an individual’s identity or their stream of consciousness continues to live after the death of their physical body. According to various ideas about the afterlife, the essential aspect of the individual that lives on after death may be some partial element, or the entire soul or spirit, of an individual, which carries with it and may confer personal identity or, on the contrary nirvana. Belief in an afterlife is in contrast to the belief in oblivion after death.
In some views, this continued existence takes place in a spiritual realm, and in other popular views, the individual may be reborn into this world and begin the life cycle over again, likely with no memory of what they have done in the past. In this latter view, such rebirths and deaths may take place over and over again continuously until the individual gains entry to a spiritual realm or otherworld. Major views on the afterlife derive from religion, esotericism and metaphysics.