Note that Mercutio does not say this famous phrase—"A plague o' both your houses"—once as an isolated statement. Rather, he voices the sentiment repeatedly as he lies dying.
Remember, in act 3, scene 1, Mercutio gets baited into a duel with Tybalt, fighting in Romeo's honor (after Romeo refuses to accept Tybalt's challenge). Tybalt slays Mercutio in the duel and then runs off, leaving Mercutio to die. This is the context in which Mercutio makes this repeated refrain.
For Mercutio, it is an expression of resentment, not only against Tybalt (his killer) but also against Romeo himself. The two houses have been engaged in a vicious feud with one another, and Mercutio blames the feud, and the families partaking in that feud, for his death. Indeed, note the literal meaning of these words: Mercutio is wishing severe sickness on both the Montagues and the Capulets. Thus, Mercutio, as he lies dying, is wishing death on those he holds responsible.
Of course, Mercutio's resentment sidesteps the degree to which Mercutio himself holds personal responsibility in contributing to his own death. Mercutio was the one who responded to Tybalt's taunts. Mercutio insisted on fighting that duel, and these dying words can thus be understood to reflect an element of self-deception on his part, as he ignores his own role in this sequence of events.