There are likely two major reasons:
1) God created creatures with freewill, therefore what is freewill if there is nothing to decide to go against – in this case the eating of the tree which was at first forbidden? The God of the Bible emphasizes the ability for his creatures to enjoy the gift freewill, but then where would the freewill be if there were only a perfect paradise in which one could do no bad via free choice? Remember with freewill there is an opposite – if there is to be freewill one has to be able to “obey” or “disobey” the rules, same with committing evil and doing good – for good to exist there has to be evil – for us to know what light is there has to be dark.
2) It is also a way of God showing “authority” over his creation, in other words he instituted only one law (not eating the fruit from the tree) in the Garden of Eden, but because of mans fall we now have to sit with ten laws (10 Commandments).
Adam and Eve likely did not heed the words of God like they should have when God said: “You shall not eat from it or touch it, or you will die.”
Nevertheless, God has the right to show authority over creation for it is his, and thus he showed this via planting the tree in the garden.
If God created the entire universe with all that is in it from absolute nothingness, and then everything from mere matter, then he is worthy of his position of power, and thus would warrant our full attention and friendship.
Furthermore, God in essence could have created 3 types of worlds, we inhabit the 3rd kind, as follows:
1- A robotic world where we have no choice but to bow to God and do his will regardless if we wanted to or not. In fact we would not even be having this discussion if this was the world God created for us. What is truly most important to God is our acceptance of him, there is no point us offering him our riches and material wealth as he would have made it – what is truly valuable in his eyes is us choosing him.
2- A chaotic world – in a sense similar to deism – in other words God would have created the world and be disgusted with it, or become bored with it, and simply move on. This would be evidence of an indifferent, unloving God that would not care to interject into the lives of a mere human species, or any other species for that matter.
3- A world of freewill – this is opposite to a robotic world where we have a choice to follow God or to reject him. However, the Biblical message assures us that mans rejection of God has resulted in chaos, and this would make sense as we can see this in daily life via abortion, prostitution, murder, pride, greed, lust, the list goes on. However, despite this the Biblical God seems to have chosen to stick with us through this (like he stuck through much with ancient Israel). It is that he only wishes us to exercise our freewill to either chose him or to reject him.
In Genesis we see that God allowed Adam and Eve to do “anything” they wanted as long as they did not eat from the forbidden tree. If the tree was not there Adam and Eve,including us, would simply be robots and nothing more.
Being free agents Adam and Eve could have avoided the temptation, but then Satan in the symbolical form of a serpent succeeded in tempting them to disobey God and use their freewill to go against him.
To be truly free in the sense of being free one would have to exercise choice – if that tree wasn’t there then what freewill were we exercising?