Besides a title reference (and some arguably Shakespearean-sounding language in the famous opening monologue, including the iambic pentameter* line "To boldly go where no [one's] gone before"), this is the first episode to grapple with Shakespeare in a major way.
And it does so quite well—and quite optimistically. Hurtling through space in the twenty-whatevereth century, Macbeth and Hamlet are still part of a theatre company's repertoire. And even then, innovative things are being done with the script—we see Macbeth stab Duncan, though the text leaves that offstage. At least, that's the case with the Folio printing—perhaps they've discovered a Quarto of the play in the twenty-whatevereth century.
In any case, we get part of Macbeth here at the beginning of the episode. Toward the end, we get a bit of Hamlet, too (with a little Julius Caesar thrown in for good measure). And that part spills over into the plot of the show, in which a crewman seeks revenge for the murder of his father (and mother): Hamlet's own (partial) predicament.
Links: A Gateway to Star Trek Information at Wikipedia.