God and the origin of sin
If God knew mankind would sin, wasn't he setting mankind up for failure by placing the tree in the garden? Couldn't God have made mankind without sin since he is perfect? If God created everything, didn't he also create sin?
God certainly could have prevented sin from corrupting his creation, but he does not reveal in the Bible why he did not choose that course of action. What God did reveal in Scripture is the following:
God created everything, and at the end of the sixth day of creation he pronounced everything “very good” (Genesis 1:31). All was perfect in God’s creation. Sin was absent. At some point thereafter angels rebelled against God and were cast into hell (2 Peter 2:4). Through Satan’s temptation in the Garden of Eden, Adam and Eve sinned against God (Genesis 3). Sin clearly came into the world through people’s actions (Romans 5:12). God is removed from wrongdoing of any kind; he is holy (James 1:13; Exodus 15:11; Isaiah 6:3). God certainly knew that sin would infect and corrupt his creation. In eternity he formulated his plan to rescue the world (Revelation 13:8), and in time he carried out his plan in the person of his Son Jesus Christ.
When it comes to our questions of God that the Bible does not answer, we do best to adopt the attitude of the apostle Paul: “Oh, the depth of the riches of the wisdom and knowledge of God! How unsearchable his judgments, and his paths beyond tracing out! ‘Who has known the mind of the Lord? Or who has been his counselor?’ ‘Who has ever given to God, that God should repay them?’ For from him and through him and for him are all things. To him be the glory forever! Amen.” (Romans 11:33-36)