Of course, at this point Hamlet is very much in his melancholy moment, despairing, having "lost all [his] mirth." He speaks these wonderful words about the grandeur of humanity, only to follow them with, "to me what is this quintessence of dust? Man delights not me -no, nor woman either." He is fed up with the world and the injustices he sees in it.
And then of course there is Act 3, scene 1, "To be, or not to be." Such a famous speech, everybody and their dog knows it, it must be hard for an actor to step into the role of Hamlet knowing that he will have to perform this speech. As Jack says in Slings and Arrows:
When an actor starts this famous speech the audience is so keenly aware that they are watching a play because they, too, know these famous lines. It almost ruins the illusion of the theatre. Shakespeare could not have foreseen this speech becoming so famous, but maybe it helps further the play. Maybe Hamlet is just "some guy acting", and this monologue points that out in a very real way, with everyone in the audience who ever had an English class reciting along with him, "to die- to sleep. To sleep- perchance to dream."
But, as overdone as this speech is, I do enjoy it. There are some great, deep philosophical questions discussed. He starts out with the very blunt assertion that life is suffering, that is is "a consummation devoutly to be wished. To die" and "to end the thousand natural shocks that flesh is heir to." Hamlet, especially, is aware of how unfair this life can be, learning that his uncle murdered his father and then married his mother. It would be simpler to die and not deal with this terrible world. But then, maybe killing oneself isn't going to be better, "that the dread of something after death- The undiscover'd country, from whose bourn no traveller returns- puzzles the will, and makes us rather bear those ills we have than fly to others that we know not of?"
We do not know what comes after this life, it may be better, but it may be worse. And so, it is best to simply endure the heartaches of this life, because these we know.
But where Hamlet is a little wishy-washy here, contemplating death and the consequences of death, after the play-within-the-play scene he is determined. People often talk about Hamlet's uncertainty, his hesitancy to kill his uncle, but as soon as he has found irrefutable proof that his uncle murdered his father he is ready to act and is at once almost rash and impulsive. "Now could I drink hot blood And do such bitter business as the day would quake to look on." He is now determined to wreak his vengeance on his mother and his uncle, even going so far as stabbing who he thought was his uncle hiding in his mother's room.