Especially since, being omniscient, he must have known that they will break his law. Being omniscient, he must have known that they will not heed his law. So he punished them for doing what he knew they would do, which he himself could easily have avoided.
You are missing something: If God is all knowing and all powerful, it follows that God intentionally created Adam and Eve so that they would break the divine commandment. In effect, Adam and Eve may not have followed the word of the law, but they did follow the intention of God. Given how meticulously theologists have been studying and considering the Bible, I would be surprised if someone had not already followed this line of thought and come up with some conclusions.
As I remember it, there are two creation myths in the Bible, and the myth of Adam and Eve is believed to be the older of the two. There is the possibility that the myth of Adam and Eve predates the Jewish switch from many gods to just one (who may not have started out as being almighty), so it is likely that the story was written to be taken at face value.