When God created man, he created him with the fore knowledge that man would eat from the forbidden tree, and even with the knowledge that man would bring sin into the World; God created the tree in the midst of the garden. God also created the tree of life in the garden, and told man that of every tree of the garden he could freely eat except that when he ate of the tree of the knowledge of good and evil, that he would surely die.
All scriptures are quoted from the King James translation:
Genesis 2:16 and 17
And Jehovah God commanded the man, saying, Of every tree of 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.
I have often wondered why; if God has the knowledge of good and Evil, why having that knowledge is so abhorrent that it is a death sentence to man. God knew that man would choose to disobey him and eat of the tree of the knowledge of good and evil, and he also knew that man would do so before eating from the tree of life.
Gen 3:22 And Jehovah God said, Behold, the man is become as one of us, to know good and evil; and now, lest he put forth his hand, and take also of the tree of life, and eat, and live for ever -
Gen 3:24 So he drove out the man; and he placed at the east of the garden of Eden the Cherubim, and the flame of a sword which turned every way, to keep the way of the tree of life.