When the outcome of a situation is the opposite of what one would expect, that is situational irony. In "Richard Cory," as the poem describes the character, readers believe he is a person who has everything going for him--he has it all. Readers understand why the townspeople--"we people on the pavement"--would envy him, wanting to be in his place.
Richard Cory has good looks: he is "clean-favored and imperially slim." He has good manners and breeding: he is "a gentleman." He has nice clothes and a good presence about him: he is "quietly arrayed" and he glitters when he walks. Yet he doesn't seem to be conceited or to put on airs: he is "human." Not only that, he is extremely wealthy--"richer than a king"--at least to the people who are living in poverty, working for wages that don't even allow them to buy meat.
All these virtues that Richard Cory has make it seem likely that he would be happy and satisfied with his life. Yet he must not be, because he ends up committing suicide. This is ironic because it is so unexpected.
Another irony of the poem, however, is that the "people on the pavement" curse their bread. Instead of being thankful for what they have and finding joy in their lives, they wait "for the light" and wish that they were in Richard Cory's place. This is dramatic irony--when the reader knows something the character doesn't realize. The personae in the poem, the "we," don't realize that their envy robs them of their joy, but readers can contemplate that if Richard Cory's money didn't buy him happiness, then the speakers' unhappiness with their lives is not due to their financial situation either.
"Richard Cory" contains obvious situational irony, since the character who has everything going for him kills himself. It also has dramatic irony because readers understand what the speakers in the poem don't realize, namely that their lack of happiness cannot be alleviated by financial gain.