After seeing his mother remarry so quickly after his father's death, Hamlet is traumatized to the point where he begins to distrust everyone, especially women. Earlier in the play he treats Gertrude unkindly, complaining that she is weak and lustful. In the following soliloquy goes as far as saying, "Frailty thy name is woman."
This suggests that his sense of trust his hurt, and he feels a deep sense of abandonment. As the previous answerer already mentioned, in Hamlet's mind Ophelia has betrayed him by sharing his private love letters with her father. His reaction, however, is unquestionably disproportional to her action. He treats her very cruel tells her to "get thee to a nunnery."
In his mind this is about more than the letters. He is angry at his mother for his actions, and feels a sense of abandonment after yet another person he loves as done something he did not like.
In the play Hamletby William Shakespeare, there exists a theme which deals with the issue of trust. Hamlet is rather disgusted with the actions of his mother Gertrude and his uncle Claudius. He feels betrayed, and also feels that they have betrayed his father by marrying. In the issue of Ophelia, Hamlet appears to have been much in love with her. The letters that he wrote to her were of a very intimate nature. In these letters he professed his love in different ways. He wrote love poems telling her "Doubt thou the stars are fire; / Doubt that the sun doth move; / Doubt truth to be a liar; / But never doubt I love." This is written to her and intended for the eyes of no other. She betrayed that trust by giving them to her father, who then read them to Claudius and Gertrude.