Every culture has a concept of the afterlife, people fear death and therefore want to believe that death is not the end. Obviously the idea that there is life after death defies natural biologic rules of how death works. So, without relying on magic or alternate physics, how could the afterlife be scientifically explained?
You may be interested on the reasearch of a doctor called Sam Parnia. He published a book called What Happens When We Die, in which he proposes we try to study out-of-body experiences (OBE's) within the limits of science.
He proposes this by applying such experiments as having paintings in key places in surgery rooms, so that if someone has an OBE and sees the painting, they can document it. He also proposes an hypothesis - and this must be emphasized, it is not a theory, it will only ever become a theory if this is scientifically proved - that consciousness does not exist within the brain, it only interfaces with the brain, which is how an OBE may be possible. He goes into detail on how during OBE's the brain of patients is practically dead - during key moments, the ECG goes flat - and despite that, people wake up after the surgery describing how the whole thing went, and sometimes things that happened outside of the surgery room as well.
Let's pretend for a moment that what the doctor proposes is factually real. Our minds exist in more than three dimensions, which is why we can't see minds as they move through space. They are attached to a body somehow between conception and birth, and detach from the body after death.
Since our memories are stored as patterns in the brain, this explains why we don't have memories of our past lives (if you allow for reincarnation) or from the time when we weren't born yet (otherwise). It may be, though, that only the bulk of our memories is stored that way. A small fraction of it may be contained in the "soul", which is why we can "recover data" from OBE's.
This explains afterlife in a somewhat simple way - not much more (fictional) science is needed to make it feasible in the world that you are building.
We're living in a computer simulation
There are many cases where scientists have simulated the evolution of systems, and computer programmers have come up with many variants on the idea (Stack Overflow even has a question about it!). 3D Virtual Creature Evolution, for instance, simulates how fit organisms are as they evolve in different ways, and thus "the fittest" survive, according to Darwin's principles.
This can actually all be done using evolutionary algorithms, used in computational evolutionary biology. Let's say that we're living in a simulation, where more powerful beings have created an artificial universe to study how new civilizations and species arise. Those organisms that fail in some way - because others are better adapted to certain conditions - die, according to the principles of natural selection.
However, the aliens decide to do a sort of "runner-up" simulation, for lack of a better phrase. While creatures with the best adaptations survive in the primary simulation, the aliens keep some of the other top-performing variants around to see what the next most optimal configurations are. This becomes an afterlife, so to speak.
A complete answer would require us to scientifically define the essence of a living individual. My answer will not include that, but instead merely assume that such an essence can be identified and we can explore its thermodynamic properties.
In every scientific theory, there is an error term to account for measurement errors and nonmeasurable differences between each experimental setup. It is always probabalisic. It does not state that the real world has probabilities, merely that the best predictive models we use are dependent on probabilities to capture that which we do not understand. If the interaction of this "life essence" after "death" was incapable of interacting with the world in a way which is detectable different from a probabilistic distribution, or were to choose to only interact in such a way, science would never be able to identify it. It would forever hide in the noise in every experiment they run.
The fun part is exploring the many ways this could occur. There are myriad. So many that I gave serious consideration to closing this question as opinion based. If someone suggested to me that every person alive had a unique answer to this, or even multiple answers to this, I would not challenge their claim. However, there are a few general patterns that I have found intriguing to explore.
The first is similar to HDE226868's answer. If the "life essence" of an individual shifts in a higher dimension in such a way that its old content is replaced with thermal noise, that essence could move elsewhere without science noticing. This is particularly interesting because such actions are remarkably similar to the strange concept of negentropy which is associated with living creatures, and only living creatures. Such an shift could be a translation in a dimension that we are simply not aware of, a computer simulation moving data from one region to another, or even the result of careful code multiplexing such as Gold Codes occurring on time scales below that of a plank-moment which reduce the cross-correlation between the living and the dead to nearly zero. Any one of an infinite number of solutions like this works so long as the final result is that science cannot detect the life essence after someone dies because it blends in with the noise.
Another approach might be to suggest that life after death is simply very low energy, and actively avoiding being subject to scientific experimentation. Scientific evidence depends on the assumption that each experimental result is repeatable. A skilled collective of "dead" essences might be able to massage the data from scientific experiments to obscure their own interaction.
Another interesting one is to note that we don't really understand our own life essence. If there's an afterlife, what's to say that life isn't more than it lets on. Perhaps it's not that the scientific experiments don't show the existence of these life essences, but rather that these dead creatures living out their afterlife train the living to simply ignore all evidence of their existence. This would raise doubts about the fundamental assumptions of scientific measurement at its core, but is not disprovable by empirical means alone.
The options are myriad. These are merely ones which have the benefit of working with nearly any definition of an afterlife out there. If you are more specific about the characteristics of your afterlife, whole new classes of options open up. There is literally no limit to this answer. You can explore to your heart's content for your entire life, and still never even scratch the surface.
What is the essence of a sentient being?
A human consists of protons, neutrons and electrons. A rock also consists of protons, neutrons and electrons. Indeed, the protons, neutrons and electrons the rock consists of don't differ in any way from the protons, neutrons and electrons we consist of. And with the right size of rock, even their number will be roughly the same.
So what makes us different from a rock? Well, it's the arrangement of those protons, neutrons and electrons. We are not really matter, but structure. Or said differently, we are information.
On the preservation and destruction of information
A general rule of quantum mechanics is that information is not destroyed. Indeed, there's a big controversy about this about whether this still holds for black holes; that this controversy even exists shows the importance of that principle.
However there's a catch: In observations, information apparently is destroyed. For example, if we observe an electron that initially is in a so-called superposition of two states, we observe one state or the other, and afterwards it's state is changed according to our result, and there's no way to recover what the original state was.
Let's suppose that process is real (whether it is a real process, or just a perceived one, is one of the points different interpretations of quantum mechanics disagree), and suppose that despite of this, we assume that information has to be conserved. Then clearly there has to be some place where this information ends up, and that place is not inside the observable universe (because quantum mechanics tells us quite clearly that the information is no longer accessible to us). So under those assumptions, one would conclude that there's a mechanism which allows information to "escape" from the observable universe, and moreover at least one of the processes where this happens may involve sentient beings (who observe a quantum system).
Putting it together
So on one hand, the essence of a sentient being is information, and on the other hand, quantum mechanics together with some assumptions (which, I must stress, are not implied by quantum mechanics) leads to the possibility of information leaving the observable universe. So it is not a completely unreasonable idea that the information that makes up a person might also possibly leave the universe at some point. Obviously when this happens, that's the inevitable death of that person in the observable world, so one might as well assume this happens on every death.
Of course that still leaves open how/why that information would remain organized in the "afterlife world" in a form so that it would still remain a sentient person recognizing itself. But obviously that depends on laws completely outside the observable universe, and therefore cannot be explained (let alone confirmed or falsified) by science.
Who measures the duration of an afterlife? Is it an external observer or is it the person experiencing the afterlife?
A valid afterlife might be us experiencing some of our strongest memories for what we feel is an eternity but externally measured is mere seconds as the body decays.
Either my consciousness and all my memories are the result of a particular arrangement of the grey goo that I keep between my ears, or I am something more. Since you are looking for a purely scientific answer, lets ignore the "something more" option. In which case, your question boils down to...
In an nearly-infinite universe that is just one of an infinite number of universes, will there ever exist another skull full of grey goo which is identical in every way to the one I possess right now?
The answer to that is strongly linked to the definition of infinity. On any truly infinite spectrum, every possible value drawn from a limited (non-infinite) scope will probably happen an infinite number of times along that spectrum.
Since my skull has a limited capacity for holding grey goo and since that quantity of grey goo can only be configured in a limited (albeit vast) number of ways; the number of (non-something-more) human consciousnesses that can possibly exist has to be a limited number. Adding that to the large number of skull-full of grey goo configurations which do not result in a human consciousness, we still are dealing with a limited number.
So across all of space and time, each of us should look forward to living at a minimum, an infinite number of lives.
Everything we physically are when we're alive gets scattered after our death. As our bodies deteriorate, the connections between our numerous neurons burn.
As of science, there is no life after death by definition. Now, since everything known to us dies with us, you first need to prove there is "life next to life" (aka the soul).
Science is not much about souls. The soul is basically the idea that human beings have an essence that goes beyond their physical bodies. Science being a lot about the physical world and not at all about essentialism, proving the soul seems to go against the scientific method. This gives quite a lot of restrictions on what the soul can be and do in order to be provable.
Maybe we actually live in a n-dimensionnal world and our 3D minds are just a projection of something bigger (and probably outside of time). After death would be an
exit 0. Maybe we are ourselves the shadows in Plato's cave. Anyway, how do we prove that?
One necessary property of one's soul would be for it to interact with the person's brain. Even just observing the brain should be enough to have an impact (say hello to quantum physics).
Now, external observing should have impact on the quantic properties of your brain's atoms. Not just one atom but most atoms (the mind resides in the network and its interactions). Find a way to spot quantum oddities and that should be a piece of cake!
Now, how do you intend to fund my work?
The Idea of an afterlife is not against or current understanding science. What is Life after all but energy and memory. If you destroy a computer drive you destroy your ability to access that memory stored in the drive, but the memory it self is not touched and continues to exits even if it is inaccessible. Your body could function a lot like a computer drive. If it is destroyed then memories and personality stored in your brain becomes inaccessible but not destroyed.
Also remember that science is not a static construct, It chances as new discovers are accepted into the scientific model. Even if there wasn't any possibility for some type of life after death in our current scientific model doesn't mean that will remain so as time goes by. You could simply say that some scientist came up with a theory for life after death that was accepted by the scientific community.
You can consider each instant of time as a new Universe, so each instant of your existence is the afterlife of the previous instances. Fundamentally, we're all just algorithms. At every computational step this algorithm changes, something is added or removed from the memory which means that after such an operation it will not respond in the same way to exactly the same input. Some algorithms will be capable of having a subjective experience of a "past" where they had less information. But this identification of an algorithm to its "previous version" is not an unambiguous identification, because we're not only adding information, information will also be removed.
So, there is no escape to the conclusion that your life expectancy is always just one computational step of the algorithm that defines you right now. The fact that we don't intuitively see it that way and that even years later most of us will still feel like being the same person, means that we already stick to an afterlife interpretation, even if we are hard core atheists.
On the long run, there is no real "continuation" of a given person. Since we are all just finite state machines, there are only a finite number of computational states available for us. Each state should actually be considered a different person or animal or whatever, but what matters is that the number is finite. Each state will have a finite memory of a "past". The only thing that's truly eternal here is the set of states. The time evolution is itself just an illusion, all the experiences of all the possible persons that can exist, just exist in their own time. In that sense we never really die, as Einstein put it:
Now he has departed from this strange world a little ahead of me. That means nothing. People like us, who believe in physics, know that the distinction between past, present and future is only a stubbornly persistent illusion.
There are two possible Afterlives. One depends on the survival of the personality after death. The other depends on the existence of a Heaven or a Hell.
This is inspired by Nigel Kneale's TV play The Stone Tape. Essentially the human personality is recorded at the moment of death by the surrounding environment. Under certain the recorded personality can be replayed. This means the post-mortem state is that of a sort of ghost. Whether this 'spectre' is a conscious entity or not is an open question. Considering that this 'recording' degrades over time, if you were conscious this could agonising.
To get ourselves Heaven and/or Hell, we can start with the assumption that exists parallel realities which might be a form of parallel universe. For simplicity, let's call them a dimension. This dimension is closely bound to our spacetime and while they can only weakly interact with our sate of existence they can interact strongly with what might be the 'shadow aspects' of our nature. This consists of the pure information generated by the structure of our bodies and minds. Normally the 'shadow aspects' are firmly welded to the corporeal state of our bodies. However, on the moment of death the 'shadow aspects' can be plucked out of our world and taken into this parallel dimension or two.
The 'shadow aspects' can be thought as the soul. This isn't accurate, but be that as it may, lots of people will think it so. While the 'shadow aspects' are intangible and immaterial in our world they become incarnated into something resembling physical reality in the other dimension(s).
Should one dimension be a nice world, and the other not so nice and, if the truth be told, is downright nasty. Then between the two dimensions we now have a Heaven and Hell. Of course, the alien entities in charge of the two dimensions will be pursuing their own agendas which may be radically incompatible with that of mere mortals
Now whether the survival of these 'spectres' in these dimensions of Heaven and Hell is eternal and unending, ie, whether they are immortal, is an open question. And the OP isn't asking about this. So we will leave the departed in their Afterlives and hope they can enjoy what is in store for them there.
In your world, quantum physicists could find actual evidence that the world is not actually real. We know that human consciousness has the capacity to dream up imaginary worlds and fool itself into thinking they're real worlds in which it is living. Billions of people regularly do so while they're dreaming during sleep. When someone is dreaming, they typically are so engrossed in the dream that they believe it is real. In your fictional universe, quantum physicists could find actual evidence that this world we call real is just such a long-lasting dream. When we die, one dream ends. It may be followed by another dream, or an actual awakening from dreaming altogether.
If this world is a dream, then it also means that our body and the person we think we are are part of that dream. It will disappear when we awaken or move on to another dream with another world. Sort of like if you dream at night that you are a crocodile living in the Amazon river. When the dream ends, the crocodile "dies." But you weren't really that crocodile. So you, the real you, goes on to have some other dream (maybe being an elephant this time) or you actually wake up from dreaming altogether.
So if this life is just a dream, where is the real you? Who is dreaming? The meta physicists in your world may not actually know yet. Is the dreamer in some other physical world, sleeping? All we know is that they are sentient. After all, in order to experience anything, there must be sentience. If you feel like it, you could leave the actual identity of the dreamer open. The scientists may still be working on answering that. After all, how could they answer it while they are still dreaming?
I am not saying quantum physicists have actually proven such a thing (although the fields of quantum physics and metaphysics are full of wonderful mysteries), but it could certainly work for a fictional story.
Inspired by Rupert Sheldrake's "morphic resonance hypothesis": All living structures bring about an "imprint", a kind of resonance in the matrix of reality. (Mix in some universal quantum entanglement nonsense here to give the idea a physics base.) The human mind, conceptually the physically and electrically interconnected neurons, is such a structure. Its imprint or resonance continues after death and is able to either have consciousness of its own or shapes another such structure, which leads to rebirth.
If with afterlife you mean an entity with your thoughts, memories, and so on... You will most probably can't ever explain that scientifically, but on the other hand if what you want is to explain scientifically the persistance of what we once were, that is quite possible. First off matter cannot be created nor destroyed, thus what you are (in its bits and pieces -I mean energy and atoms-) has always been here and will always be. When you die you won't disappear, your atoms will move (you will be eaten by the worms, part mixed with the sand, whatever. Thus your atoms will pass from one place to another but they won't dissapear and even if they dissapear the really don't, they will just transform into energy).
"We are made of star dust" and that is literally. We have always been here and we will always be :)
If you look at how John Searle deals with the idea of consciousness in his famous Chinese Room gedankenexperiment, you will rapidly surmise one of the fundamental problems with our scientific understanding of consciousness, which persists as a very unwelcome (to the functionalists) eyesore to the present day: there is no accounting of the qualia in our present materialist zeitgeist.
Searle's proposition seems to be that it is possible all matter experiences qualia, and that therefore it is quite possible there is "something it is like to be a rock," for example - it is only that sentient beings are the one form of matter which is able to express its experience of qualia. From this, therefore, it is easy to surmise that in such a universe, one would not stop experiencing things just because one died; instead you would stop experiencing what it was like to be a living human and start experiencing what was like to be a dead human, or a pile of ash, or whatever you became after that. Hell, given long enough, parts of "you" could quite possibly experience what it is like to be a living human again.
Of course this "afterlife" ends with the eventual heat-death of the universe when matter itself ceases vibrating and decomposes into a perfectly distributed energy field persisting across an infinitely large universe for an infinite period of time, during which course the accumulation of random events may well lead to another big bang event and the recreation of another universe in which different matter would come into existence - but there would be no continuity between that universe's matter and our own that I am aware of, and thus your experiences would cease then and there.
Beings with advanced technology replicate the information in our brains
This was the solution used in the Riverworld books (where it was done by aliens), and various people have speculated that our distant descendants (or intelligent machines 'descended' from AIs we create) might do this in the far future--the first such speculation I know of comes from Nikolai Fydorov in the 19th century, who started an intellectual movement known as Russian Cosmism, and the idea has also been prominently advocated by the physicist Frank Tipler in his Omega Point speculation.
The particular cosmological model Tipler assumed--a Big Crunch in which the universe eventually stops expanding and begins to contract until it reaches a final singularity similar to the Big Bang--is no longer favored as describing the future of our universe, both because the density of matter doesn't seem to be higher than the critical density which would be needed to halt the expansion, and because there appears to be a cosmological constant that's causing expansion to accelerate rather than slow down and reverse. But the main elements needed for this "scientific" notion of an afterlife would be 1) it is possible for future beings to reconstruct the past history of the universe by measuring all the particles in the universe and reconstructing their past configurations (or possibly they could have some kind of time travel technology for this), and 2) the computing power available to our descendants increases forever without any upper bound, so that any 'resurrected' beings can exist in the afterlife indefinitel. Tipler proposed a method of endless computing based on compressing computations into smaller and smaller times in the moments leading up to the Big Crunch singularity, but in this paper physicist Freeman Dyson proposed a different method that would work in an "open" universe that expands forever and has zero cosmological constant.
I know of at least one current cosmological theory in which both these could be present, found in this paper by two respected string theorists, Leonard Susskind and Raphael Bousso. It's rather technical and to understand much of anything in it you probably need at least a basic familiarity with ideas like quantum decoherence, the many-worlds interpretation of quantum mechanics, the string theory landscape, the universe tunneling into a different vacuum state (a future state with zero cosmological constant which they label "the hat" because of the way it appears on a diagram), causal diamonds and holographic entropy bounds (particularly Bousso's covariant entropy bound discussed on the last page of that link, which can be applied to determine the entropy--which is directly related to the informational capacity for observers that want to perform computations--of causal diamonds). But see the discussion on p. 32 where in "Postulate II" they propose a definition where to be truly "observable", it must be true that "the world is big enough that the observable can be measured infinitely many times", and section 3.4 starting on p. 33 about the hypothetical "census taker" in the distant future who performs such a series of infinite series of measurements to reconstruct the multiverse's past history, with the comment on p. 35 that "we conclude that Postulate II is satisfied for all observables in the hat. Since both postulates are satisfied, quantum mechanical predictions can be operationally verified by the Census Taker to infinite precision." Then on p. 39 they relate observations made in "the hat" (the future infinite universe with zero cosmological constant) to physical observables in the "finite causal diamonds" which lie in its past (regions of spacetime with nonzero cosmological constant that will eventually transition into the zero cosmological constant state via quantum tunneling): "Any (necessarily approximate) observable in the finite causal diamonds of the multiverse can be represented by an exact observable in the Census Taker’s hat." Finally on p. 41-43 they make clear that the Census Taker is actually able to use this information to reconstruct the history of all the prior finite patches (finite causal diamonds) that existed in the past of the "hat", writing on p. 42 that "Over time, the Census Taker receives an unbounded amount of information, larger than the entropy bound on any of the finite causal diamonds beyond the hat. This means that the Census Taker will receive information about each patch history over and over again, redundantly."
So to sum up, in this model, at some point billions of years in the future our universe will experience a spontaneous tunneling event which changes the vacuum state, causing some apparent changes to the laws of physics--according to the paper here (and the talk summarizing it here) this would probably be fatal to organic life, but various kinds of structures like stars and planets would persist so perhaps some appropriately-structured type of artificial intelligence could survive too. If so, these AI would then find themselves in a new type of universe where it would be possible to continue computing forever, and would also encounter (and presumably join up with) other AI that survived similar transitions from other patches of spacetime with different vacuum states. This community of AI could continually perform measurements on incoming photons and other particles which would give them more information about these past patches of spacetime, eventually leading to the possibility of complete ancestor simulations which would include detailed and accurate simulations of all the beings that lived in these past patches, including us (such simulations would be equivalent to the notion of mind uploading--of course it's a philosophical question whether an upload of me would have the same type of consciousness as me, or whether it would make sense to say it is me but just made out of different atoms--note that the molecules that our own brains are made of probably get replaced almost completely every few months, so there's a case for saying only continuity of pattern matters, not continuity of actual physical particles).
If we imagine that the future superintelligences might have some empathy for puny beings like ourselves, or some moral commitment to bettering the lives of sentient beings everywhere no matter how small, you could imagine that after any being dies in the historical simulation, they make a copy of its mind at the point of death (perhaps repairing brain damage or deterioration) and release it into what they would consider the "real world" of this distant future, giving all beings a kind of afterlife. This could be pretty interesting as a science fiction setting, a sort of combination of the Riverworld books with everyone who ever lived coexisting, and fictional worlds like Orion's Arm set long after a technological singularity, where human-level beings coexist with really vast superintelligences (Orion's Arm, which is supposed to take place about 10,000 years in the future, imagines a whole zoo of different transapients occupying various levels of superintelligence, from just-above-human-level basic transapients to godlike archailects--it's all made up of course, but this kind of stuff can make for a colorful science fiction setting). As far-fetched as this whole scenario may seem, it has the advantage of being grounded in ideas about physics and cosmology that are mainstream among present-day physicists, which can't be said of most other afterlife ideas (like Tipler's big crunch scenario, or the human mind being a product of something other than the structure of the physical brain observed by neuroscientists, like a higher-dimensional 'soul').