Measure for Measure is one of Shakespeare's darkest "comedies." The play is obsessed with death and corruption (in society and the legal system) and offers up one of the most artificial "happy endings" in the history of Western literature.
Was Shakespeare growing tired of writing comedies? Go to "What's Up With the Ending?" if you want to know more about this.