One of the best philosophical expositions of how evil works comes from Jacques Maritain’s Existence and the Existent (p 96-99, Image Books edition):
Liberty of the created existent and the line of evil
What is the metaphysical root or precondition of evil in the free act? If that act is evil, that is to say wounded or corroded by nothingness, the reason is that before producing it, the will from which it emanates has already in some fashion withdrawn from being. It has done this freely, but without having as yet acted, or acted evilly (otherwise we should be in a vicious circle, and the fissure which we are seeking, through which evil introduces itself into the free act, and makes it evil, would already be a wicked act).
In one of his most difficult and most original theses, Thomas Aquinas explains on this point that the emergence of a free and evil act resolves into two moments—distinct, not according to the priority of time, but according to an ontological priority. At a first moment there is in the will, by the fact of its very liberty, an absence or a nihilation which is not yet a privation or an evil, but a mere lacuna: the existent does not consider the norm of the thou shouldst upon which the ruling of the act depends. At a second moment the will produces its free act affected by the privation of its due ruling and wounded with the nothingness which results from this lack of consideration.
It is at this second moment that there is moral evil or sin. At the first moment there had not yet been moral fault or sin, but only the fissure through which evil introduces itself into the free decision about to come forth from the person, the vacuum or lacuna through which sin will take form in the free will before being launched into the arteries of the subject and of the world. This vacuum or lacuna, which St. Thomas calls non-consideration of the rule, is not an evil or a privation, but a mere lack, a mere nothingness of consideration. For of itself, it is not a duty for the will to consider the rule; that duty arises only at the moment of action, of production of being, at which time the will begets the free decision in which it makes its choice. Non-consideration of the rule becomes an evil, or becomes the privation of a good that is due, only at the second of the two moments we have distinguished—at the moment when the will produces some act or some being; at the moment when it causes the choice to irrupt; at the moment when the free act is posited, with the wound or deformity of that non-consideration.
And still, without as yet being an evil or a fault, that vacuum or lacuna, that non-consideration of the rule, was already free; for it depends upon the freedom of the will to look or not to look at the rule. The will has not acted, has not looked. And St. Thomas says that the freedom of the will sufficiently accounts for the fact that the will has not looked at the rule and there is no need to seek farther. Ad hoc sufficit ipsa libertas voluntatis. We are faced here by an absolute beginning which is not a beginning but a “naught,” a fissure, a lacuna introduced into the warp and woof of being. And we must henceforward do violence to all the words in the language, for they are all constructed in function of being and yet must now be related, in an inevitably paradoxical form, to the domain and the works of non-being and nothingness. The first cause (which is not an acting or efficient cause, but is dis-acting and de-efficient), the first cause of the non-consideration of the rule, and consequently of the evil of the free act that will come forth from it, is purely and simply the liberty of the created existent. The latter possesses the free initiative of an absence (or “nothingness”) of consideration, of a vacuum introduced into the warp and woof of being, of a nihil; and this time this free initiative is a first initiative because it does not consist in acting freely or allowing being to pass, but in freely not-acting and not-willing, in freely frustrating the passage of being.
It follows from this that whereas the created existent is never alone when it exercises its liberty in the line of good, and has need of the first cause for all that it produces in the way of being and of good, contrariwise, it has no need of God, it is truly alone, for the purpose of freely nihilating, of taking the free first initiative of this absence (or “nothingness”) of consideration, which is the matrix of the evil in the free act—I mean to say, the matrix of the privation itself by which the free act (in which there is metaphysical good insofar as there is being) is morally deformed or purely and simply evil. “For without Me, you can do nothing”; which is to say, “Without Me you can make that thing which is nothing.”