The words COMEDY and TRAGEDY commonly refer to the ways in which dramatic conflicts are resolved (inside of and outside of theatre)...
Whenever a tragedy occurs, the inherent confusion cannot end until such time as everyone affected has recognized what had taken place ...and has: learned, forgiven, forgotten, and re-established (his or her) identity within a functional social group.
Whereas a comedy typically ends within a "group celebration" -- e.g. a betrothal or wedding (accompanied by music and dance). The emphasis is on integration inside of the group. It's a recommitment to the sharing of life, together. If there has been a disruptive presence -- a source of anti-social discord, then that person typically has to reform their ways -- else be punished, or banished from all celebration by the group.
Thus, a "comic celebration" is looking forward to a more meaningful communal life, hence the ubiquitous ending for romance novels (romantic comedies) ..."and they lived happily ever after."