Shakespeare used madness in the play as a vehicle for advancing his plot quite nicely in the directions that it needed to flow. It is these appearances of madness that reveal the character traits of almost every character in the play.
1. In Act 2 Scene 1 Ophelia is upset because she met with Hamlet and believes that he has gone mad. She meets with Hamlet right after he has seen the ghost of his dead father who asked him to avenge his death by murdering Claudius so he was distraught. Ophelia tells her father his madness is caused from love for her.
2. In Act 3 Scene 1 Claudius observes a meeting between Ophelia and Hamlet believing that Hamlet's madness is caused by unrequited love. He soon learns, after Hamlet shuns Ophelia, that Hamlet's madness is much more explosive than Claudius thought and not caused by love at all. This realization fears Claudius because he wonders if Hamlet's madness has anything to do with Claudius murdering his father for throne and wife. He orders Hamlet sent away.
3. Ophelia was acting "mad" in Act 4 Scene 5. She is singing about death and betrayal in front of Gertrude, Claudius, and eventually Laertes. This act of madness is what foreshadows the eventual deaths of Laertes and Claudius. Without this act of madness, Laertes would not have felt the fury that drove him to challenge Hamlet to the deadly duel.
Although you could choose three different instances just with the character of Hamlet, I also was thinking of Ophelia when she completely lost it over her father's death, as well as Claudius when he sees the players enact the circumstances he used to kill his brother.
Hamlet feigns madness to throw off the king and keep him from suspecting that Hamlet suspects/knows that he killed old King Hamlet. One instance of this occurs in Hamlet's conversation with Polonius wherein Hamlet calls Polonius a "fishmonger." This leads Polonius to believe that Hamlet's madness is caused by his supposedly unrequited love of Ophelia (Act II, scene ii).
Ophelia's madness is very real and is the result of, I believe, two things - one is Hamlet's rejection of her as part of his own fake madness, and also the murder of her father. This incredibly sad scene can be found in Act IV, scene v.
Claudius appears to be going mad when he reacts as Hamlet hoped he would to the scene enacted by the players, demonstrating the method for murdering old Hamlet. He yells for lights to be lit, then runs from the room, which definitely appears to be mad behavior (Act III, scene ii).
This image of madness is varied and enriched throughout the play with the variety of characters who experience madness, either real or feigned (or something both), and what this madness ultimately leads to for everyone involved.