Just as Genesis tells us that God created everything inherently good, it was after that humans and some angels became evil of their own free choice. Other religions contend that there has always been an eternal struggle between good and evil, between God and the devil. That is not Christian teaching.
Scripture speaks of a great hevenly battle between the Archangel Michale and the other angels, Lucifer and the third of the angelic host who followed him (Rev 12:3-9). The fallen angels were cast into hell and, once there, became known as devils or demons, whereas the two-thirds of the good angels went to heaven and are still called angels.
If God knew beforehand that Lucifer would be bad, why create him at all? Why not just spare the universe the devil in the long run? Fair question. Again, remember that God creates good. Only creatures with free will can choose evil and sin, and then face the consequences of their choice.
If God prevented the devil from being the devil from being created merely because later, after being created, Lucifer would freely choose to go bad, then it’s the same as not having a free will at all. If only those who choose good are allowed to exist, what freedom is that?
Were the evil people and angels not allowed to exist before they even made a choice, it would not be just. It would be condeming a person before they commit the crime. Punishment must come after the fact, not in anticipation of it. That would be like a parent disciplining a two-year-old child for bad behavior she will commit as a teenager.
Answer from “The Catholic Answer Book: The 300 Most Frequently Asked Questions” by Rev. John Trigilio and Rev. Kenneth D Brighnti.