This question includes two aspects: 1) God's knowledge of Satan's temptation and human sin, and 2) why God would create humans who would or could sin. First, did God know Satan would rebel against Him and then successfully tempt Adam and Eve? The Bible clearly states that God knows all things. For example, 1 John 3:20 teaches, "God is greater than our heart, and he knows everything." Psalm 139:17 declares, "How precious to me are your thoughts, O God! How vast is the sum of them!"
If God knew the Fall was going to happen – that Satan would rebel and Adam and Eve would sin – why did He create them?
If God knew Satan would successfully tempt Adam and Eve, why did God create humans with the ability to sin? Though the Bible does not explicitly answer this question, many principles can be seen. First, God is the only perfect being. As Romans 3:4 says, "Let God be true though every one were a liar." Therefore, every created thing, including humans, would have the ability to do wrong or to sin.
Second, God can use even sin as part of His perfect, sovereign, divine plan. Though sin displeases God and He is not the author of it, the sin that began in the Garden of Eden served as the basis for which human sin entered the world, revealing the necessity of One who could conquer sin and death. This came through Jesus Christ, as Romans 8:2 teaches, "For the law of the Spirit of life has set you free in Christ Jesus from the law of sin and death."
Third, God created humans with freedom of choice. The only other alternatives were to create people without choice or to not make people at all. People without choice would create a robotic type of existence that does not reflect the plan of God for the world. Instead, God created people with the ability to make choices, including right and wrong, as part of His sovereign creation. Again, our human understanding cannot completely comprehend the ways in which God's sovereign plan and our human choice work together, yet Scripture reveals both. God's perfect plan continues to move forward despite human sin and clear commands to believe in His Son Jesus Christ and to live a life that honors Him.
Ultimately, however, God created Adam and Eve with the ability to sin to bring Himself maximum glory. In ways beyond our complete comprehension, God's glory is best displayed in the way He has chosen to create humanity, including allowing for our sinful nature. Part of this display of glory will be seen at the end of time when the curse is ended and sin is removed. This time, described in Revelation 21—22, shows that the curse of sin is not permanent for those who believe in Christ, but will be removed when we are in His presence forever.
Is God omniscient? What does it mean to be omniscient?
Why did God create humanity?
Does humanity truly have free will?
Why did God allow the Satan and the demons to sin?
How can I get right with God?
Truth about God