God created us and told us that there are things he would like us not to do. “Sins.”
But if he doesn’t want sin, then why create humans who sins? God sounds a little confused, he creates sin and then hates it!
God said “let there be light” and there was light. God said “keep Shabbat” and… well we try. Why can’t God just snap sin out of existence if he hates it so much??
The answer is that God created the world because he wants a relationship, and you can’t have a relationship with someone who is controlled by you or anything else. A real relationship is when two free-willed individuals choose each other. Nobody wants to be married to a robot, we marry another human. Maybe the argument could be made that marriage to a robot would be easier than marriage to another person; no fights, no give and take, no pain. But that would defeat the whole point of marriage.
This is why God gave us the power to sin, the power to hurt him. We cannot imagine the pain that we cause God when we sin. But God chooses to continue to feel that pain if it means a relationship with us.