To best answer your question, I will use the classical definition of comedy. Historically, a comedy involves a sympathetic character who achieves a happy ending. In the Shakespearean sense, a comedy almost always ends in marriage.
While Franz Kafka’s The Metamorphosis is not traditionally viewed as a comedy, one could make the case that is certainly has comedic elements. The novella includes the absurd in Gregor’s transformation into the giant insect, an impossibility that is treated matter of factory within the context of the story.
The story also contains humor, a feature of comedy. When Gregor discovers that he can crawl along the walls and ceiling of his room, his mother witnessed him doing this and promptly faints. This is an example of dark humor, but it is funny that she is all right having her giant insect son continue living in the apartment but is horrified when he does something insects do.
Another way in which the novella is similar to comedy is its ending. While Gregor’s death could be interpreted as tragic, the Samsa are almost relieved. They look forward to downsizing to a smaller apartment now that he’s gone, and Grete feels liberated from the constant care of her brother. In fact, the story ends with the contemplation of Grete’s marriage:
"Growing more silent and almost unconsciously understanding each other in their glances, [Mr. and Mrs. Samsa] thought that the time was now at hand to seek out a good honest man for her. And it was something of a confirmation of their new dreams and good intentions when at the end of their journey the daughter first lifted herself up and stretched her young body."
This ending stands in almost bizarre contrast to Gregor’s sudden death, yet fits with the ironic tone of the novella. Upon the discovery of Gregor’s body, Mr. Samsa dryly remarks, “Well. . . now we can give thanks to God.” This reaction goes against expectations that one would be grieving over the death of a son. This treatment of Gregor’s death make the novella venture on black comedy, a particular type of comedy that examines dark themes through the lens of humor.
The fact that the story ends in a kind of marriage plot is Kafka’s nod to the novella’s comedic stylings—even if his message is not exactly light-hearted.