"And out of the ground made the LORD God to grow every tree that is pleasant to the sight, and good for food; the tree of life also in the midst of the garden, and the tree of knowledge of good and evil." Genesis 2:9 "And the LORD God commanded the man, saying, of every tree in the garden thou mayest freely eat: But of the tree of the knowledge of good and evil, thou shalt not eat of it: for in the day that thou eatest thereof thou shalt surely die." Genesis 2:16-17
"And the LORD God said, Behold, the man is become as one of us, to know good and evil: and now, lest (for fear that) he put forth his hand, and take also from the tree of life, and eat, and live forever: Therefore the LORD God sent him forth from the garden of Eden, to till the ground from whence he was taken. So he drove out the man; and he placed at the east of the garden of Eden Cherubims, and a flaming sword which turned every way, to keep the way of the tree of life." Genesis 3:22-24 "He that hath an ear, let him hear what the Spirit saith unto the churches; To him that overcometh will I give to eat of the tree of life, which is in the midst of the paradise of God."
Revelation 2:7 "Blessed are they who do His commandments, that they may have right to the tree of life, and may enter through the gates into the city." Revelation 22:14
The tree of life was in the garden of Eden and Adam and Eve and everyone else could eat of it freely sustaining them, in their righteous state, before God, for all eternity. The original plan was that mankind would live forever in a sinless world. That's still the plan. But due to Adam's sin, if God had let them eat of the tree of life after sinning, they would live for all eternity in their sin.
So God protected the tree of life until which time He removed it and put it into paradise, which is heaven. If you were to partake of the tree of life before you were born again you would live in your sins forever, but Jesus became the propitiation (substitute for your sin) so that you could be made sinless before God and eat of the tree of life and live forever.
When you cross over unto heaven, you will have access to the tree of life, to eat thereof and live forever in your sinless state. In this story remains the mystery of God; that part that God has not disclosed to us through His Word.
Why the tree of life and why the tree of the knowledge of good and evil? Even though we do not have a full explanation, I think it noteworthy that God did tell us about these trees and what they do. I think it was for a specific purpose.
To be like God and to stay being like God you have to have free will; Free will to sin and free will to choose not to sin. These choices make us like God, however eternity with a people that still choose to sin would be no heaven. That's why Jesus came to die for you and me; to make us righteous; to put within us the Spirit of God and to give us the power to overcome sinful behavior. When we die, we are ushered into the presence of God sinless and ready to eat of the tree of life freely. We will do so out of choice, not coercion. We will lie in eternity with God freely serving God and God freely serving us. Read Luke 12:37