Ophelia is, at the outset of the play's action, a beautiful girl whose father is very concerned with gaining and consolidating his power in the court of Denmark. So when Polonius learns of Ophelia and Hamlet's love affair, he forbids her to pursue it and she, being the obedient daughter, breaks it off. Hamlet is confused by this, along with his greater confusion about his father's death and all that goes with it, and Ophelia is hurt and trying to make sense of it for him while also being loyal to her father.
When Hamlet loses it (or appears to), then kills her father, Ophelia's sanity is lost and she raves and cries and eventually kills herself. Shakespeare presents all of these phases in the way that she speaks and interacts with the other characters (obviously) but spends a great deal of time developing her character as one of the innocent victims of all the intrigue in the court between Hamlet, Claudius, Hamlet Sr., Gertrude, et al.
Ophelia is one of the lesser characters in the play who is in the court of Elsinore because of her father being the king's counselor. She serves as a female interest of Hamlet's. As a love interest, we are given conflicting images of the relationship. We are told of "hot love on the wing". Even at the end of the play at Ophelia's grave, Gertrude laments that Ophelia would have been Hamlet's bride. What we actually see in the play though is completely different. The two do not actually meet until 3.1 right after the "to be" speech. When they meet on stage Hamlet greets her as he would a stranger: very formal. Compare the Captain in 4.4, when Hamlet says, "I humbly thank you sir." and to Osric in 5.2, "I humbly thank you sir." to Ophelia in 3.1 , "I humbly thank you, well." That's as civil as it gets between the two. This dichotomy is an important thematic element in the play.
Ophelia also serves, within the context of the garden metaphor, as a flower of Denmark whose stewards in the play are primarily Polonius and Laertes. Her mind is supplied by them. When we first hear from her she is with her brother Laertes and he is lecturing her. Her first words are a question, "Do you doubt that?" Her second, a statement that just agrees with Laertes. Only at the end of this duet does she become declarative, but then she merely parrots back to Laertes what he has told her.
After Polonius appears and takes over the discussion from Laertes, Polonius asks her directly about what she thinks of Hamlet's advances. She has no answer: "I do not know my Lord what I should think." She can only describe Hamlet's approach as "honorable" and "holy". Then in "The Mousetrap" she admits to Hamlet, "I think nothing my lord." Of the 60 uses of the word "think" in the play, Ophelia uses the word as a positive expression of her own mind just once. That is in 4.5 when thinking of her father being laid "i'th' cold ground." After her father's death is when she becomes divided from herself and her fair judgment. But, at this point, all she can do is recite pieces of poetry and songs similar to HAL 9000 singing "Daisy" as Dave pulls his memory banks in "2001".
Her end comes at the moment, her brother's mind is turned to the dark side by Claudius. Having lost all care from her men in the play she dies from over-watering. Laertes:"Too much of water hast thou poor Ophelia,". In part she signals the sickness and decline in Denmark under the ruling family.