Work made to produce laughter, and the shape of a story that ends well. Both are about relief arriving.
Greek komoidia, from komos (a revel, a merry-making procession) + aeidein (to sing); comedy was first specifically a sung, festive performance before it named a shape of story that ends well.
Work made to produce laughter, and also the shape of a story that ends well — both are, at bottom, about relief finally arriving.