Schoolboy Oskar Schell sends himself on a mission to find the lock which fits a key he's found in the closet of his father who's recently died in 9/11. Days turn to weeks and eventually he's bursting to tell someone, that someone ultimately being "the renter", an elderly gentleman who lives with his grandmother. During one of the film's breathless montage sequences, he mentions the school's production of Hamlet:
It's a thematically pertinent choice as both Oskar and the Prince are experiencing the death of a parent in unbelievable circumstances. The removal of the the skull mask to reveal Oskar's face fits all the relevant iconography into the shot making it entirely recognisable especially since as the novel indicates, he's playing Yorrick rather than the Hamlet.
Hamlet has a much stronger presence in Jonathan Safran Foer's novel. Throughout Oskar mentions his Hamlet rehearsals and carries a copy of the script about with him on his quest, "so I could memorize my stage directions while I was going from one place to another, because I didn't have any lines to memorize".
In the film, Oskar notes that there are more people alive in the world now than have died in human history and that eventually there won't be enough places in the world to bury them. In the novel, he says instead "if everyone want to play Hamlet at once, they couldn't, because there aren't enough skulls."
The book also features a section about the resulting production, "it was actually an abbreviated modern version, because the real Hamlet is too long and confusing, and most of the kids in my class have ADD. For example, the famous "To be or not to be speech" [...] was cut down so that it was just "To be or not to be, that's the question."
This brief wiki is also worth reading for dialogue and thematic parallels: " Oskar, has a similar issue to the one represented in Hamlet's soliloquy - What is our purpose, what is the point to our life? After his father dies in 9/ll, Oskar struggles with why he should even live his life, What is the point of doing something if you could die tomorrow?"