[There are] essentially three different lines of evidence that lead us to conclude that the idea of the afterlife is probably a product of our brains, starting off with our brains. That is, we're natural born dualists. We tend to think that mind is separate from brain because our brains can't perceive themselves. So we naturally think there's something else sort of floating around up there. But we know for a fact that if you remove part of the brain through stroke, surgery, injury, from an impact or whatever, whatever the function was that was destroyed in that part of the neural tissue, that function is gone. That part of the mind is gone forever unless it's rewired.
[Secondly,] our primary function of our brains is to run our bodies. And we have a neural network in our left hemisphere that coordinates all the inputs from the body into a cell. So we have a sense of self that we can decenter. We can imagine being somewhere else. Close your eyes and picture yourself on a beautiful California beach. Almost everybody will see themselves -- their bodies down on the sand, not looking out through their eyes but actually seeing their bodies. So that's kind of what happens in an out-of-body near-death experience.
And three, we know from extreme sports, from maintain climbers, from Arctic explorers, that they have a third man factor. They have a sense of presence, like there's somebody else nearby, even though there clearly isn't. This could be oxygen deprivation, it could be cold, it could be starvation, it could just be loneliness. So our brains concoct this alternative person -- another sense presence that we can't sense being inside of ourselves, so we think of it out there -- an extension of ourselves. And in a way, a mind that continues into the indefinite future of an afterlife is like that. (
source)