In this scene, Ophelia tries to return some love-tokens that Hamlet, in the past, had given her. She says that he gave her with them "words of so sweet breath composed as made the things more rich". All of this indicates that Hamlet and Ophelia were close enough for him to give her presents, and with them, promising and romantic words. To imagine the now so bitter Hamlet in such soft and endearing terms is almost unbelievable, especially considering his forthcoming rant. We also learn that Hamlet has become distant when Ophelia says that the "rich gifts wax poor when givers prove unkind", saying his unkindness to her has made his gifts of little value.
The main point behind Hamlet's succeeding rant and rave against Ophelia is not a direct hit to her, but probably an indirect chastisement to his mother, who he suspects is listening in on the conversation. He takes the opportunity to express his rage against what he considers his mother's fickle and incestuous actions of late. He insists that women make "monsters" of men, are not "honest and fair", are "breeders of sinners", should be "chaste as ice, as pure as snow", and shouldn't marry. In fact, there should be "no more marriages" at all unless you are already married; if so, "all but one, shall live"--no multiple marriages for them.
So, even though Ophelia "was the more deceived" that Hamlet had loved her, his anger at his mother has tainted that love, and turned him against her, and all women.