The second Shakespeare reference in The Next Generation takes place in the second episode (for which, q.v.). The third reference comes along with the second appearance of the entity known as Q.
Q is an omniscient, omnipotent entity who shows up periodically to tease or to test the human beings on the Enterprise. In this scene, he's thumbing through Picard's Globe Illustrated Shakespeare . He give us a bit of Hamlet, followed by a modernized-to-the-year-2363 version of Jaques' "All the world's a stage" speech from As You LIke It. A sampling of Macbeth follows, to which Picard responds with some more Hamlet, specifically, this:
Picard says he's saying this sincerely—without Hamlet's irony and without (though he doesn't say this outright) Hamlet's "Yet, to me, what is this quintessence of dust" that tends to take the edge off the lines. When Picard compares man to a god, Q (who is an omniscient, omnipotent entity, remember—something of a god himself) is appalled. And rightly so!What a piece of work is a man. How noble in reason, how infinite in faculty. In form and moving how express and admirable, in action how like an angel—in apprehension how like a god!
What we tend to forget about that speech, especially when it's taken out of context, is that Hamlet is talking to Rosencrantz and Guildenstern, who have already admitted that they are working for the King. Although Hamlet's purposes in uttering this in particular to people he knows will report what he says to his nemesis are unclear, it is clear that we can't take it at face value. At face value, it's quite an appalling claim!
I prefer the passage that may lie at the back of it: Psalm 8:3-5.
But back to the scene in question. Here it is!When I consider your heavens,
the work of your fingers,
the moon and the stars,
which you have set in place,
what is man that you are mindful of him,
the son of man that you care for him?
You made him a little lower than the heavenly beings
and crowned him with glory and honor.