Addressing your second question, I believe that in examining the "techniques" that Hamlet used, we learn about the insufficiency and the danger of being covert. Hamlet should have confronted his uncle face to face. But he doesn't, he uses this play, and the theme of everyone hiding their feelings and beliefs continues. More subterfuge occurs, with Polonius hiding and with the plot to send Hamlet away, and both of those things end in tragedy and death. Had Hamlet just confronted his uncle, then he would not have given his uncle time to try to escape, he would not have been in the position to kill Polonius, and he might have been able to unseat Claudius immediately and take the throne.
In Act III, scene 2, Hamlet adds 16 or so lines to the play, "The Murder of Gonzago," which the traveling players that arrived at Elsinore are planning to enact. He makes sure that the exact method for killing his father, reported to him by the ghost, is acted out by the players for Claudius, Hamlet's uncle. It is Hamlet's hope that the play will "catch the conscience of the king" - in other words, if Claudius is truly guilty of murdering old King Hamlet by pouring poison in his ear while he slept, then seeing this scene acted out in front of him should cause some kind of a reaction in Claudius. If he is innocent, which Hamlet highly doubts by this point, then he will not react and Hamlet will then know that the ghost was false.
As far as a moral lesson, as you mentioned in your question, perhaps it is simply that guilt will show itself, particularly when a person is confronted with the sin of which they are guilty. Claudius, despite being a treacherous, evil man, still could not handle seeing his evil actions thrown right in his face. It completely unstabilized him and the demeanor he showed to the world.
Check the links below, particularly the one about the "play-within-a-play" motif used by Shakespeare in his plays. Good luck!