The tree of life is primarily mentioned in Genesis and Revelation. It was a tree in the midst of the garden of Eden.
In Genesis 3:22 (NIV), God says
He [Adam] must not be allowed to reach out his hand and take also from the tree of life and eat, and live forever.
Thus, the tree provided eternal life.
After Adam and Eve were forced to leave the garden of Eden, and “at the east of the garden of Eden [God] placed the cherubim and a flaming sword that turned every way to guard the way to the tree of life.” (Gen 3:24)
I think God probably kept the tree of life for a period to show that a way to eternal life still existed. The very fact that the way of the tree of life was kept open, rather than obliterated altogether, gave people hope. Perhaps it could be hoped, in the mercy of God, that the way to the tree of life in the midst of the garden would one day be again opened up again.
Of course, the tree didn’t really make you immortal, any more than the tree of the knowledge of good and evil poisoned you. Granting of life and death is always in God’s hands. But the trees were helpful physical symbols of the choice to be made in serving God or self.
Although the tree of life in Eden appears to have been real, it was symbolic of the granting of eternal life by God. So after that particular tree died (which it must have done), immortality was still possible by the grace of God.
The tree is mentioned again several times in Revelation. For example, Jesus says
To the one who conquers I will grant to eat of the tree of life, which is in the paradise of God. (Revelation 2:7)
Again, the tree of life is symbolic of the path to eternal life. Essentially, Revelation completes the story that began in Genesis. In Eden, the way to life was shut off, but Christ has opened it up again. Through Jesus, we can eat from the tree of life (i.e., receive eternal life).
Jesus was probably hinting at this when he said “I am the way, and the truth, and the life. No one comes to the Father except through me.” (John 14:6). There is also an echo of this in the curtain being torn in the temple, opening the way into the Most Holy Place where the cherubim were (guarding the way to God).
In effect, the cross of Jesus became our tree of life.