Legal comedy
Shakespeare wrote several plays that hinge on the fair administration of laws, and especially on the conflicting demands of justice and mercy. The Comedy of Errors and Measure for Measure, along with The Merchant of Venice, are comedies that contain the possibility of a protagonist getting killed because of an inflexible law.
Shakespeare's solution in The Merchant of Venice is similar to that of many modern "courtroom dramas": an inspired lawyer (really Portia in disguise) gets Bassanio off on a technicality. As well as being highly dramatic, the scene explores in some of Shakespeare's finest language the debate between the seemingly conflicting demands of justice and mercy. Paradoxically, Portia pleads eloquently for mercy, but seems merciless herself when Shylock fails to respond.