The above answers do an excellent job of treating situational irony, so I'll deal with dramatic irony.
Dramatic irony occurs when the reader/audience knows more about a character's situation than the character does. The one main effect is that it gives the reader a sense of superiority, or detached superiority. The reader not only seemingly discovers what is revealed, but feels superior for doing so.
An example of dramatic irony is in the beginning of Shakespeare's Macbeth Act 1.6, when King Duncan and Banquo describe Macbeth's castle and the atmosphere around it with words like sweetly, pleasant, and delicate. The reader knows something they don't: that Macbeth and his wife are inside plotting to assassinate Duncan. Macbeth's castle is anything but a place of sweetness, pleasantness, or delicateness. This is dramatic irony.
Enotes says, "situational irony: such as when a pickpocket gets his own pockets picked."
In other words, it is when the prank backfires on the prankster, the terrorist becomes a victim of terrorism, etc...
The effects are often humorous, a kind of poetic justice: the punishment fits the crime, fitting retribution.
So says one of my favorite websites, Sarcasmsociety.com:
Situational Irony occurs in literature and in drama when persons and events come together in improbable situations, creating a tension between expected and real results. An example of this would be a scene where a man and woman are sitting at a bus stop and start to converse. The woman divulges some of her deepest darkest secrets. The man listens and advises her, and the woman thanks him and gets on her bus. After she is gone the man takes off his heavy coat to reveal that he is in fact wearing the garb of a priest. The irony lies in the fact that the woman never knew that the man she was talking to was a priest, but the audience does and the reality of what the audience knows about why the man was so helpful and understanding is different from the reality the woman experienced.
Sometimes the effect of situational irony is humorous; at other times it is tragic. But it is almost always shocking. Either the protagonist or the reader is surprised. Nadine Gordimer's short story "Once Upon a Time," is filled with situational irony. The family's extreme efforts to protect themselves and their belongings wind up destroying one of them. In William Golding's Lord of the Flies, the fire that was used in an attempt to kill ends up saving the boys. In both cases, the ending is unexpected and surprising. The reader may guess, but the success of the irony is in its surprise, but then in the recognition that the surprise was fitting and appropriate, not arbitrary or random. For instance, the situational irony in a wonderful little short story called "The Storm," lies in the fact that the main character at first seeks shelter from the storm and at the end of the story the storm becomes her refuge. The success of this ending lies in the fact that it is surprising, but totally in keeping with the events of the story. It is this kind of twist that Alfred Hitchcock used so skillfully in many of his movies. In Connell's short story "Most Dangerous Game," the readers are surprised when the hunter becomes the hunted, but again, when we look back at this strange turn of events, we see that the author has prepared us well for this development through quite a bit of foreshadowing. It is this kind of surprise and predictability that increases our enjoyment of literature. We can predict and make guesses, but we like to be surprised. This surprise can delight or bring tears.
The effect of situational irony is almost always humor, but what's more important than this is the effect of humor. Humor destroys barriers that a greater truth can be revealed. Taking a look at the example above, the woman at the bus stop likely needed a priest to divulge her deepest secrets to. There are many things in society that can't be plainly spoken, they must be revealed in a figurative or clever way.
The author will use irony (dramatic or situational) to get away with making a comment that couldn't be made plainly. Usually this comment is about humankind, society or a social phenonmenon.