Hamlet is using a metaphor to compare Denmark, his home, to a prison. This metaphor shows that, like someone in prison, Hamlet feels as if he is trapped and being watched all the time.
OR
Hamlet uses a metaphor.
Hamlet compares being in Denmark to being in a prison.
The metaphor shows that Hamlet feels trapped.
EDG 2022