The main literary element at work in "Richard Cory" is irony. However, in order to establish the hard-hitting irony at the end of the poem, Robinson sets a happy tone from the start. Richard Cory is a happy-go-lucky gentleman whom everyone in town admires. The speaker says, "still he fluttered pulses when he said/ "Good-morning," and he glittered when he walked." The tone here is happy, which sets up the ironic ending beautifully.
Imagery also plays a part in setting the tone. In the first stanza, he is described as "a gentleman, from sole to crown,/ clean favored, and imperially slim." Two word choices depict an image of royalty - "crown" and "Imperially." These are words that describe a person who has it all, not a person that will commit suicide.
And therein lies the irony. In the last stanza, the speaker describes how everyone wants to be like Richard Cory and yet, "one calm summer night,/ [Richard Cory] went home and put a bullet thorugh his head." Cory's ironic ending offers the message that even those who look like they have it all, might be unhappy in some profound, unseen way.