In Shakespeare's early plays there was a clear distinction between comedy and tragedy. The audience will have known when they attended whether to expect to laugh and be diverted, or to become sad and thoughtful. In his last plays, Shakespeare, now of course much older and also famous enough to risk criticism, blended features of both genres in his plays so the Winter's Tale and The Tempest are regarded by some as tragi-comedies.
Shakespeare was always experimental with the dramatic form. He broke rules with his later plays by allowing a death in a play called a comedy. He did not end the plays with the light and happy resolution expected of comedies, and found in his early plays, but with deeper and thought-provoking words and situations.