This is one of those answers that has changed and become muddled since it was first used by the Greeks.
Originally, comedy was a noun and referred to the play itself. Comic was an adjective that typically related to a person’s behaviour. Comic also came to mean a situation that was unexpected, turned the entire story topsy turvy and became the basis for the comedy and comedic action. In other words, comedy is a drama that has been turned upside down.
There are many subgenres to comedy now such as the comedy-drama, tragicomedy, etc.