Irony is generally described as a contradiction between appearance and reality. It is often mistakenly attributed to situations that are simply bad luck, as is the case in the Alanis Morrisette song ‘Ironic’. She sings about it raining on your wedding day or being stuck in a traffic jam when you’re already late. These are not actual examples of irony, but rather grim coincidence.
Irony requires a situation that was intended to have a particular result having the complete opposite happen. For instance, if you had especially planned your wedding to be held in a location where it never rains on a date when it wasn’t forecast to rain, and then it rained, that would be more akin to irony.
Movie villains can often be the victims of dramatic or situational irony as their attempts to cause a nefarious desired outcome can often result in the opposite effect, usually by way of their actions ultimately leading to their death. Commonly, something they say do early in the film comes back to haunt them in a kind of cosmic karma.
These deaths are often revealed as twist endings which are satisfying to the viewer as they are clever links to earlier events and actions in the film. It is also undeniably enjoyable to watch a villain perish due to their own actions, even if it's also a little dark.