God created Lucifer, who was a cherubim who covered.
This passage below refers to Lucifer, before he turned evil:
"You were the anointed cherub who covers,
And I placed you there.
You were on the holy mountain of God;
You walked in the midst of the stones of fire.
You were blameless in your ways
From the day you were created
Until unrighteousness was found in you." (Ezekiel 8:14-15)
So Lucifer was created to be good. However, Lucifer turned away from good to do evil.
"Your heart was lifted up because of your beauty;
You corrupted your wisdom by reason of your splendor." (Ezekiel 28:17)
God did not create robots, but He created angels and people to have freedom to choose.
Lucifer decided to become prideful and do evil. He left God's ways.
Evil is simply a path that is not good. It is a turning away from good, or a corruption of good.
[As an analogy example, we can take a look at math. According to mathematical principal, we know that 1+1=2.
A child in a math class can give a different answer than 2. But he would be marked on his test as wrong and getting 0 points.
Anyone can give a different answer than the correct answer. But they are all wrong.]
If we look at sin in a similar way, anyone can deviate from God's law, but he would be sinning. Just as anyone can give an incorrect answer, but that answer would be always wrong.
So it is person or angel who decides to sin or give an incorrect answer, it is not the teacher who is wrong or God who is wrong for giving the law.
God created angels and humans, knowing some of the angels would turn evil and knowing humans would sin.
But God also knows that He would redeem mankind through Jesus, and most of the angels would remain good.
God created all of us, looking forward to our relationship with Him and how all things will be restored.
God loves us, and seeks a good relationship with all who love Him. That's why He created.
"Jesus, the author and perfecter of faith, who for the joy set before Him endured the cross, despising the shame, and has sat down at the right hand of the throne of God." (Hebrews 12:2)
So God looks forward to the joy in our relationships with Him.
And God doesn't let evil triumph. God overcomes evil with good, and teaches us to do the same.
"Do not be overcome by evil, but overcome evil with good." (Romans 12:21)
Good can overcome evil. God knows this and so He created.
He gives everyone the freedom to choose. Let us choose to do good.