As a woman in this particular historical moment, Ophelia is subject to the whims and demands of the men in her life. She is used as a pawn by her father, who asks her to spy on Hamlet to learn of his true intentions, and by Hamlet, who insults her and tells her that he never really loved her. Ophelia doesn't have a confidante to turn to, and she is caught up in the schemes and acts of deception which ensnare the men in her life.
No one seems to care much about how Ophelia is dealing with rejection, but she can at least somewhat rely on her father to look out for her. When Hamlet murders Polonius, Ophelia finally snaps.
We don't see this mental collapse onstage, but when Ophelia appears onstage again in act 4, scene 5, her crazed actions have become the subject of court gossip. A gentleman tells Gertrude that Ophelia "beats her heart" (4.5.5), speaks nonsense, and is easily angered. She also "speaks much of her father" (4.5.4) and has grown suspicious of the world around her. Ophelia sings tales of death and of lost love and tells Claudius that she cries when she thinks of the way they have lain her father "i'th' cold ground" (4.5.46).
Ophelia is a broken woman. Feeling that the world is unpredictable and that there is no one who truly considers her best interests, she slips into a world of madness following the death of her father.
The last time we see Ophelia on stage, prior to her father's murder by Hamlet, is just before the start of the play by which Hamlet hopes to get his uncle/stepfather, Claudius, to betray himself as the murderer of Hamlet's father. Hamlet treats her in quite an embarrassing way, making lewd comments about what "lie[s] between [a] maid's legs" and insulting her by saying that "woman's love" is brief (3.2.125-126, 3.2.175). Hamlet kills Polonius two scenes later, and when next we meet Ophelia, she is "distract[ed]" and "Her speech is nothing" according to the gentleman who tells Gertrude that Ophelia is insisting upon an audience with her (4.5.3, 4.5.9). When Ophelia enters, she sings nonsensical songs that seem to conflate her recollection of being loved by and loving Hamlet with her love for her now dead father. It is as though the grief of losing her true love, compounded now by the loss of the father who made her give that love up, is too much for her to mentally support. We don't get to see Ophelia's initial response to the news of her father's death or whether her descent into madness is gradual or quick; we simply see the effects of her double grief, and this way of presenting her current state to us is more dramatic than watching a slow decline would be. The once vibrant young woman is now, suddenly, a shell.
Ophelia is completely overwhelmed by her father's unfortunate death. He was her advisor and warned her about Hamlet's deception and forbade her to have any contact with him.
Ophelia seems to be desperately in love with Hamlet who has rejected her, asking her to "get ... to a nunnery." It is difficult for her to understand Hamlet's inconsistent actions, for he later seeks her attention again, asking to lay his head in her lap during the performance of his play and making sexually suggestive references.
It is the knowledge of her father's untimely death, the fact that Hamlet has treated her so badly, and the realization that the one she loves is responsible for her father's demise, that drive Ophelia to mental breakdown. She continuously sings senseless ditties which are a confused jumble about death, dying, lost love and broken promises. This creates great concern in both Gertrude and Claudius about her emotional and mental health. They instruct Horatio to watch her closely.
Gertrude later informs Claudius and Laertes about Ophelia's drowning. She was out picking flowers from the banks of a river. One of the boughs on which she was leaning broke and she fell into the water, still singing. Ophelia made no attempt to save herself and she was dragged into the depths by her clothes which were weighted down by the water.
It seems as if Ophelia either lost all hope and chose to die, or that she was incapable, in her mental state, to understand the danger and therefore made no attempt to save herself.
When Ophelia's father, Polonius, is killed by Hamlet in Act 3, sc. 4, Ophelia loses touch with reality. In Act 4, sc. 5, Ophelia comes into the scene with Gertrude and Claudius. Ophelia's singing and her seemingly nonsensical responses to Claudius and Gertrude indicate that she has gone mad. Later, in the same scene, Ophelia re-enters the scene when Laertes is there. She continues to utter apparent nonsense. Later, in Act 4, sc. 7, Gertrude tells Claudius and Laertes that Ophelia has drowned. Gertrude describes the situation saying that Ophelia seemed unaware of her situation when the limb broke and she fell into the water. Ophelia's reaction to her father's death is insanity. This is ironic because Hamlet tells us that he will pretend to be mad, but Ophelia's madness appears to be genuine.