The question of mental illness as William Shakespeare presents it in Hamlet has been widely debated. “Mad,” a term that was once in common use, can apply to a wide range of emotional and mental problems from which both Hamlet and Ophelia probably suffer. Hamlet is definitely grieving for his father’s death and concerned over his mother’s lack of loyalty to her late husband’s memory. His drastic mood swings may also indicate bipolar disorder. It is also clear, however, that he is feigning “madness” because he tells several characters of his plan—not only before he begins, but at several key points.
After the Ghost speaks with him and he swears vengeance, Hamlet tells Horatio of his plan to dissemble in order to trick Claudius. He tells his friend to ignore anything “strange or odd” as his plan is to "put an antic disposition on" (Act I, Scene V). Later he tells Rosencrantz and Guildenstern that he is only partly mad, “north north-west,” and that he can distinguish between reality and fantasy, or “I know a hawk from a handsaw”—the latter being a variant of “hernsaw,” or a different kind of bird.
Ophelia’s distress is of a different order. When her brother leaves, she has only her father to guide her, and Polonius has sided with Claudius and Gertrude and against Hamlet. After telling her to break off with Hamlet and not see him anymore, her father reverses himself and sets her to spy on her former boyfriend. In her conversations with Hamlet, it is clear he suspects her motives. His harsh words, including telling her that if married, she would breed monsters and that he does not love her, seem to bring on a bout of depression. She describes herself as “most dejected and wretched” in part over losing his love but also because she believes “his noble mind is… overthrown.”
The songs she later sings (Act IV, Scene 5) have a heavy sexual content, leading many critics to believe that she and Hamlet previously had a sexual relationship. She may be pregnant, as she mentions to him gifts that she wishes she could return: "remembrances of yours/That I have longed long to re-deliver" (Act II, Scene 1). Part of her distress is knowing that because he will not marry her as he had promised, she can never marry because she is no longer a "maid," that is, a virgin:
Let in the maid, that out a maid/
Never departed more….
Quoth she, “Before you tumbled me,
You promis'd me to wed.”
Ultimately, it seems that the combination of grief for her father and depression brought on by Hamlet’s betrayal and her future hopeless situation becomes too much. The balance seems to be on mourning, however, as her last song is for her father, who is “dead” and “will never come again.” Ultimately, because only Gertrude reports on her death and alleges it suicide, we cannot know for certain how she died.