It’s a good question, and I think the first answer to give is that we actually don’t know because we haven’t been told. I suspect that this is a question above our paygrade. However, we can speculate, and so here all we will be doing is offering some speculations about this question.
The most common answer to this question is that God didn’t want Adam and Eve to be robots, he wanted them to have a chance to use their free will. But a little bit of scrutiny suggests that although there is some truth to this, it is a little bit of a lame answer. Would God really want to put a temptation in the way of his dearly loved children just to see how obedient they were? It sounds a little bit like testing your children’s obedience by putting a bomb in front of them, and a box of matches to light it, and telling them not to light it. Why put it there in the first place?
What perhaps may begin to help explain the situation is the fact that the creation of humanity was not the first event in the history of revolt against God. We know at some point that Satan had rebelled against God, and in fact, we find in Genesis 3 that Satan is already present on earth. In effect, God is saying to Adam and Eve- “you have a choice. The war against me has already started, and it is inevitable that you will be tempted to join it. So, here is your choice. Will you live in perfect relationship with me, or will you join the other side and rebel against me, tasting evil?”. Of course, this does not explain how Satan sinned, or what the nature of his temptation was. That question will likely always remain out of our grasp, at least while we are in this life.
I will add one last possible deeper explanation. We know that the means by which God has chosen to defeat Satan was through humanity. We know very little about the nature of Satan’s sin against God, but it seems that Satan was an angel of God who rebelled against God. Why? He wanted to exalt himself to be like God. The kingdom of Satan is all about self-exaltation. And so when Satan tempts Adam and Eve to sin, what does he say? He says- if you eat of the fruit, you will become like gods. It’s all about self-exaltation.
How does God respond to Satan’s sin? Well, he could have made a very simple response: Zzzzz- (explosion, thunder, lightning, sizzle, smoke.) But in God’s infinite wisdom, He didn’t. He responds by creating another beautiful world- a material world, a lesser world, of dirt and water, flesh and blood, our world. And Satan intervenes into our world to bring his kingdom of self-exaltation into it- and He succeeds, and brings corruption into it, as humanity rebels against God, and chooses self-exaltation rather than self-surrender. The history of our world rolls on, and sinks into more and more chaos, but God has a plan, and is at work. And at the climax of world history, probably to Satan’s astonishment and bewilderment- God the Creator becomes a human baby. God stoops low and takes on flesh and blood, born into human poverty amongst the dirt. And Jesus Christ, God in the flesh, grows as a man, and then, if God humbling himself to become a man was bad enough, now Satan is rubbing his hands in glee- as Jesus submits himself to the hostilities of men- and is arrested, mocked, beaten, whipped, and then crucified. And Jesus Christ, the eternal God of our universe become flesh- dies as if he was the scum of the earth.
But it is in this death, this ultimate act of self-surrender, that Satan’s kingdom is ultimately defeated. This is how God chooses to defeat the kingdom of self-exaltation- by a graphic demonstration of the glory of self-surrender. And Jesus in his self-surrendering death doesn’t just pay the price for sins of humans- He also in the most emphatic way possible- responds to Satan’s act of treacherous self-exaltation with an act of incredible self-surrender- and this is the means which God chooses to defeat Satan.
So the means God chooses to defeat Satan is through the creation of humans, and their own alliance with Satan. But then Jesus demonstrates the full glory of God in becoming a human and defeating Satan in a death of humiliation before a resurrection of glory. The tree of the knowledge of good and evil was the first step along the pathway for the fulfillment of God’s plan to defeat Satan and demonstrate once and for all the futility of the kingdom of self-exaltation.