If He wanted to create this but didn't foresee the consequences, then it means that He isn't omniscient.
What is it that you think God was trying to create or produce exactly?
Because if you don't know that then how can you know he didn't get exactly what he wanted? And if he got what he set out to do, then he is omniscient.
Of course he got what he wanted. He wanted to create a human being with freedom of will and choice, with consciousness and reason. If all people should have been all 'good' what is the use of these features?
There's a joke Rabbi Mannis Friedman once told to sum it up, and I'll paraphrase-
G-d wanted to communicate with someone, have a relationship. So he went to the angels, they all went as if paralyzed - " oh You Holy, Holy One, Holy You Are"...how can You have a conversation like that? So G-d went to people, said "Let's have a relationship", they said "What's on Your mind?", G-d said "here I have 10 commandments", "what's in them?" one nation asked, "Don't steal", "Nay, not interested". So G-d went to another nation, they asked "what's in there?" "There's only one G-d, Me, no other", they said "nah what will the idols say, not interested".
Then G-d went to Israel, they said "Ok let's do it, then we see how it goes", G-d went "Here You are" and gave them His Torah, and Israel immediately made the calf thing...you know just to see how it goes... G-d said "Oh finally, these folks I can talk to".
Only a joke, but in every joke there's some truth.
If G-d wanted creation to be totally obedient, He wouldn't create humanity and stay with the robotic-like beings who won't dare, or simply can't step right or left, and stop creation at angels.