This is an interesting scene because it shows that Ophelia's madness has its origin in her recent experiences at Elsinore.
Before she hands out the flowers, she is singing songs to herself. This is evidence of her madness, yet the lyrics of the songs reference a man who is "dead and gone" with a "stone at his heal"--lyrics that possibly refer to her relationship with Hamlet. One song in particular makes it clear that she feels that Hamlet used her and threw her away, which is logically how she might feel after the way he spoke to her in the "Get thee to a nunnery" scene.
As for the flowers, she has returned to the king and queen's rooms again and starts to hand out real (or imaginary) flowers to those there. It can be a bit open to interpretation as to who receives which flowers because Shakespeare doesn't write any specific stage directions, but here is one possible way the scene would play out:
1. "There's rosemary, that's for remembrance." That is probably given to her brother Laertes so that he will remember her the way she used to be. She also gives him "pansies, that's for thoughts."
2. Next she turns to either the queen or the king. She says, "There's fennel for you, and columbines." Fennel is symbolic of flattery and columbines are representative of disloyalty and ingratitude. It seems logical that those are qualities that could relate to the queen and king for different reasons. She is easily flattered and disloyal to King Hamlet in her quick remarriage. He is disloyal to his brother.
3. Next she hands out "rue" to either the queen or the king, and for herself. Rue represents both sorrow and repentance. This could relate to any or all of them. Whoever receives the rue will "wear it with a difference" because their sorrow is very different from hers.
4. Next she hands out a daisy. Daisies are a symbol of infidelity, which most clearly associates with Gertrude.
5. Lastly she says that she would give out violets, which represent faithfulness, but that they all withered when her father died.
An Elizabethan audience would have quickly understood the significance of each of the flowers and how they all represent some aspect of her life and what she has witnessed at Elsinore in the past days and weeks.