A heroine is defined as a female character who possesses courage and other noble qualities; she is a character with whom readers are expected to sympathize. Ophelia certainly qualifies as one who has a great many noble qualities, and she is very sympathetic.
First, she is loyal and obedient to her father, and she tries to make him proud and happy by following his instructions. Polonius directs her to stay away from Hamlet because he believes the prince's professions of love are insincere (this is a point on which he is wrong, but she obeys him nonetheless). He worries that Hamlet is attempting to "beguile" Ophelia into sleeping with him (1.3.140), and so he encourages her to rebuff Hamlet's attentions even though she's in love with him. Later, after she's kept away from Hamlet, he comes to her disheveled and heartbroken, as a man suffering from unrequited love, with "his doublet all unbraced," dirty clothes, and "Pale" face, and "with a look so piteous in purport / As if he had been loosed out of hell / To speak of horrors" (2.1.88, 91, 92-94). When she tells her father, she says that she only did as "[he] did command / [...] and den[y] / His access to [her]" (2.1.120-122). She has been forced to break Hamlet's heart, and she feels terribly about it, especially because she's not even been allowed to offer him a reason for her change in behavior toward him.
Hamlet, feeling betrayed, begins to treat her as he treats almost everyone at court: with suspicion and some cruelty. He claims that he "did love [her] once" (3.1.125), and a moment later, that "[He] loved [her] not" (3.1.129). He belittles her and degrades her, telling her to go to a "nunnery," a word that refers to a home for nuns but is also slang for a brothel, implying that her behavior toward him qualifies her as a whore. Ophelia has only ever tried to do what her father has told her, and now she's verbally abused by the man whose heart she was forced to break, the man who she still loves. It is quite tragic and she is very sympathetic here, stuck between a rock and a hard place, so to speak. Believing that he has been driven mad by her actions toward him, she mourns the loss of the "noble mind" he once possessed (3.1.163). Hamlet continues to insult and degrade Ophelia, especially at the play he has staged to try to entrap his uncle into betraying his guilt, and she remains quiet, resigned to serve her father and be as gentle to Hamlet as possible, too.
Finally, Hamlet kills her father. So now, the man she loves, whose heart her father made her break, has killed that father who forced her hand. And she believes that she has driven the prince mad as well. It is all too much. Ophelia's mind can no longer bear up under her the heavy weight of her guilt and sorrow, and she goes mad. It is now that she utters the lines, "Lord, we know what we are but know not what we may be" (4.5.48-49). Thinking of her father, perhaps, she means that we may know what we are while we are living but not what we shall become after we die. Perhaps she considers her own impending death. She sings a number of songs that seem like madness but also appear to point toward a past sexual relationship with Hamlet as well as her grief over her father's death. Thus, she has been driven mad by the bad behavior of other people: her father's bad advice prompted her to break ties with Hamlet, and she interprets Hamlet's "madness" as her fault when, really, he pretends in order to fool his uncle. Her tragedy occurs through no fault of her own and is brought about by others' mistakes and her own loyalty and filial piety. Therefore, her noble qualities actually make possible her final ruin, and we are meant to find her very sympathetic as a result of her tragedy. These facts and our feelings reveal her as a heroine.