Hamlet delivers this soliloquy as a consequence of seeing his mother happy in her new position as wife to Hamlet's uncle. She appears to have forgotten her former husband (Hamlet's father) and appears to all intents and purposes to be happy in her new state as the wife of Claudius. Hamlet, obviously still grieving his father, cannot understand this attitude of his mother's and is shocked by it, producing one of the most famous quotes from Hamlet: "Frailty, thy name is woman!" Hamlet is so upset by it that he wishes he could commit suicide. In a world where love and affection can be so quickly forgotten and are so transient, what is there to live for? We can see how this affects the way Hamlet views the world: "How weary, stale, flat, and unprofitable / Seem to me all the uses of this world!"
Another high-drama moment for poor Hamlet, as this soliloquy is delivered after the Ghost of his father discloses to him how he was killed and that Claudius was the murderer. Hamlet is overwhelmed by hatred for both Claudius and his mother: "O most pernicious woman! / O villain, villain, smiling, damned villain!" Hamlet, at the ghost's urgings, promises to "Remember [him]" and pledges himself to avenging his murder by killing Claudius. He is so dedicated and fixed on this objective that he vows to forget all else except this task of achieving revenge:
Yea, from the table of my memory
I'll wipe away all trivial fond records,
All saws of books, all forms, all pressures past,
That youth and observation copied there;
And thy commandment all alone shall live
Within the book and volume of my brain,
Unmix'd with baser matter
Now, everything comes second place to his desire to achieve revenge.