During Hamlet's soliloquies, Shakespeare creates the illusion of insanity through structure, with spontaneous, erratic speech. This is achieved through short sentences and rapid changes of topic and views from Hamlet, "But two months dead, nay, not so much, not two! / So excellent a King; that was to this / Hyperion to a satyr". [I.ii.138-140] This reveals the depth of emotion and turmoil within Hamlet's mind. This is also shown further at the end of Hamlet's soliloquies. Most Shakespearean characters that, through their speech, reach a firm decision will conclude on a Shakespearean rhyming couplet. Hamlet, when in great tension, does not, which is indicative of his instability of mind and decision. .
Within Shakespeare's era madness was perceived as a lack of faith, or even the work of Satan. The reason for Hamlet's prevarication and ultimate confusion is that Hamlet is unsure whether his father's apparition, "may be the devil" [II.ii.597] and that, "the devil hath power / T"assume a pleasing shape". [II.ii.597-598] By this, Shakespeare creates dramatic tension through pretence of madness, as it can also be interpreted as playing with the devil, despite Hamlet's admission that the devil, "Abuses me to damn me". [II.ii.601].
Madness is an integral part of the play, creating dramatic tension, as the audience no longer knows how the play will unfold. Arguably Shakespeare makes madness relevant to expose the true nature of revenge, which like madness, he depicts through plot and action that it is unpredictable and often without morals. Shakespeare presents madness in many forms, in pretence, rage and true insanity. Ultimately it ends in the same fashion, death. It could be perceived that Shakespeare intended for the audience to see the true negative nature of madness through these aspects, to show that it cannot be controlled, but it manipulates you. .
Hamlet's madness is deliberate, and Ophelia's is not.