Traditionally, a comedy is loosely referred to a narrative with a happy ending (that's why Dante's Divine Comedy, though it has plenty of unhappy moments in the Inferno portion, is called a comedy in the first place). Conversely, a tragedy has an unhappy ending, and usually involves the downfall of the main character.
Let's look at The Merchant of Venice in this context. In many ways, the play has a happy ending: Bassanio ends up with Portia, and Antonio not only escapes his gruesome fate, but also finds out that he is, in fact, still rich. By all accounts, that's a classic comedic ending: guy gets the girl, nobody is poor, and everyone's having a good time. However, the play subtly disrupts this comedic ending through its treatment of Shylock; though he is ostensibly the "villain" of the play, the reader/audience tends to sympathize with Shylock, as he faces significant persecution through the story, simply because he is Jewish. As such, his downfall is not positive at all, but instead takes on tragic proportions (he doesn't even appear on-stage during the final act). The play's comedic ending is subverted by the tragic downfall of Shylock, and this is one of the main reasons why The Merchant of Venice continues to be read and studied.