The Catholic Church teaches:
“The devil and the other demons were indeed created naturally good by God, but they became evil by their own doing.”
Scripture speaks of a sin of these angels.
“You will be like God.” The devil “has sinned from the beginning”; he is “a liar and the father of lies”.
Satan may act in the world out of hatred for God and his action may cause grave injuries; nevertheless, his actions are permitted by divine providence.
It is a great mystery that providence should permit diabolical activity, but “we know that in everything God works for good with those who love him.”
From the Catholic Catechism, paragraphs 391-395