Yes, He told them not to but if you can humour me a little, why should this punishment be regarded as fitting the crime? It’s just fruit, right? Isn’t God testing our patience with such an injunction? Would you respect me if I told you not to touch my really delicious pot of lamb stew because you will be dead if you do, especially if the children are having a really tasty dinner?
You've missed exactly what Adam and Eve missed - the tree of Life. There it was in the midst of the garden.
And there it was - the Word of Life - 'the tree of the knowledge of good and evil, thou dost not eat of it.'
It isn't food. You can't digest it. Partake of it and you will die.
But another (created) spirit drew near. (For they had not taken of the Tree of Life in the midst of the garden. They had not partaken of the Word of Life which said 'the tree of the knowledge of good and evil, thou dost not eat of it'.)
And Eve hearkened and ate. And Eve gave to Adam to eat.
And in that very day, they died.
This is about human nature. It is a matter of how humanity is to Live. Adam was made a living soul and he lived and breathed. But there was a Tree of Life in the midst which he needed. And he did not partake of it.
He chose to seek sustenance from another direction. From knowledge. Rather than partake of Life, he chose knowledge. Which assumes his own ability to see aright and to do aright what he sees.
Rather than to partake of Life itself.
He wishes to be independent of the Deity (in whom is Life) who made him.
Chooses to hearken to a created spirit, encouraged by a created woman.
And he dies.
And he is banished from the garden, for he has failed in his humanity to rise to the purpose of the Creator who made humanity for a purpose.
This is profoundly and fundamentally spiritual.
It's not about physical fruit.
Most Christians would say that Adam and Eve's sin wasn't about eating fruit, but rebelling against God, their rightful and loving ruler. Sin can't be quantified in general, but especially not rebellion against God. What's the "fitting" punishment for rebels? Expulsion from the land of the ruler you rebelled against doesn't sound too unfitting. And they were still permitted to live in God's land actually, just not his special garden.
Without the introduction of prohibition, human choice would have lain dormant and faith, having no opportunity to work, would have been dead. The fruit of the tree of the knowledge of good and evil was the item of prohibition. But if you look at what the temptation was you will see that ingesting fruit is not what ruined mankind: Gen. 3:5
"For God knows that when you eat of it your eyes will be opened, and you will be like God, knowing good and evil."
The manifestation of the sin (the fruit of it, if you will) was eating from the prohibited tree. The sin itself was in rejecting God as the one qualified to delineate between good and evil for him and in taking that mantle upon himself. Adam died to the Word of God (the source of Life) as his governing authority in that moment because he claimed it for himself and internalized the desire to be his own 'god'. All of humanity has inherited that death.
The banishment from the garden was not penal but protective. Gen. 3:22-24
"Then the LORD God said, “Behold, the man has become like one of us in knowing good and evil. Now, lest he reach out his hand and take also of the tree of life and eat, and live forever—” therefore the LORD God sent him out from the garden of Eden to work the ground from which he was taken. He drove out the man, and at the east of the garden of Eden he placed the cherubim and a flaming sword that turned every way to guard the way to the tree of life."
It is not good for man to live even a temporal life in the belief that he does not need God to discern good and evil for him. God removed/cut off access to the Tree of Life so that man would not live forever in that state of spiritual death. He sent His Son to be the new access point.