Hi there. I happen to have multiple graduate degrees in the field of Hebrew Bible. I'm an academic. Hopefully I can shed some light on this.
At first glance, it does indeed seem like the God in the text is a giant a-hole. Why put the Tree of Knowledge of Good and Evil in the garden in the first place? To answer that, we need to lay some ground work to properly interpret the story:
1) Remember that the ancients did not have a scientific worldview. Today we understand that things I drop to the ground fall because of gravity. Gravity works because the Earth is a huge sphere with an enormous amount of mass. The sun sets and rises because the Earth rotates. Seasons progress at the rate they do because the Earth rotates around the Sun. In other words, life is orderly and predictable because the laws of Physics, Chemistry, etc, are orderly and predictable. But the ancients had no knowledge of this. Instead, they explained the world through mythology. So, in the Ancient Near East, the reason the world is orderly is because a long time ago, the "good gods" came in and beat up/killed/banished the "bad gods" and then set up order in the universe (e.g. the Marduk/Tiamat myth of Babylon, or the Baal/Mot myth of Caanan).
2) Genesis is written in the form of Ancient Near Eastern creation myths. Those ancient creation myths wanted to explain this fundamental question: "Why does the world work the way it does?" Genesis answers that question: A long time ago, God (YHWH) came upon pure chaos (the Hebrew of the passage makes that very clear. Google: "Genesis tohu vevohu"). He then systematically pushes it back to create perfect order. This is why the world works the way it does...because God set it up in order.
3) The Bible never claims that God is omniscient. In fact, good Jewish/Christian theology claims that he's not. Does God have all power? If he does, then (low hanging fruit) he could make a rock so big that he couldn't lift it. But then that's a logical impossibility. Here's a better question: could the God of the Bible create a being with free will and force that being to love God? The answer is no. So by definition, there is at least one thing (maybe two, if you count the rock example) that God cannot do. So, a better formulation of God's state is that (according to the Hebrew Bible) "God has all the power that can be had, but some things cannot be accomplished by power."
So now we're ready to talk about the garden (which is, remember, more like a story or a parable). God creates these two beings and puts them into paradise. Imagine a world where there is nothing bad and you KNOW that God exists (because you talk to him frequently). So now how exactly does God let them choose to love God or not? (Because remember: there must be a choice) The answer (at least, the ancient Hebrews) was to place a clear choice before Adam and Eve. The Tree represents free will. And the Tree represents the choice that everyone makes in whether or not they will love God or turn their backs. To the ancient Hebrews who wrote this story (probably finalized from earlier oral tradition around 500 BCE), the clear choice between following God or not had been made when the people of Judah chose to follow other gods. Thus, God kicked them out of the garden (the "promised land") and sent them into exile into a hurting world. The garden story is not just one which orients the reader to the world, but specifically to the present world (the one they lived in at the time).
Let me know if you have any questions. This isn't a sacred cow to me. Cheers.