God did not create sin; Lucifer did.
The Bible traces the origin of sin back to the Garden of Eden.
Genesis 1:26,27 “And God said, Let us make man in our image, after our likeness: and let them have dominion…over all the earth…So God created man in his own image, in the image of God created he him; male and female created he them.”
God is only good, holy, omnipotent, omniscient, loving, and just. Man was created in God’s character likeness with the ability to recognize and worship His creator. Adam and Eve were created perfect and without sin.
However, God also gave man a free-will. God did not want mankind to be like robots, obeying blindly without choice. God desires that “…true worshippers shall worship the Father in spirit and in truth: for the Father seeketh such to worship him.” (John 4:23) As Jesus said, “…Thou shalt love the Lord thy God with all thy heart, and with all thy soul, and with all thy mind.” (Matthew 22:37)
Back in the Garden of Eden, the sin that Adam performed was eating of the Tree of Knowledge of Good and Evil. There was nothing sinful about the tree. God did not create a sinful tree. The sin was that Adam exercised his free-will and disobeyed God. Yet, that is not where sin began. Sin began when Lucifer told a lie in Genesis 3:4 “And the serpent said unto the woman, Ye shall not surely die”
Angels also have free-will. Specifically, the angel Lucifer had the freedom to obey or disobey God’s righteous rule. Isaiah 14:12-14 explains that Lucifer was created as a beautiful angel, but he became prideful. “You said in your heart, ‘I will ascend to heaven; above the stars of God I will set my throne on high; I will sit on the mount of assembly in the far reaches of the north; I will ascend above the heights of the clouds; I will make myself like the Most High.’ ” It was Lucifer’s own free-will that created sin with his first lie. God gave a blessing to man and to angels: the freedom to obey or disobey. Lucifer (Satan) created sin by exercising that free-will to disobey.