Please explain the representation of marriage in Hamlet?
I'm afraid Shakespeare's Hamlet is a product of a male-dominated society. As enlightened as Shakespeare was in so many ways, his presentation of women, at least in Hamlet, is extremely sexist, and that deals directly with his presentation of marriage.
Gertrude is at the least full of and driven by her lust, gullible, and foolish. King Hamlet appears to have truly loved her before (and after, for that matter) his death, and is extremely forgiving toward her, telling Hamlet repeatedly to leave her out of his plan for revenge and to not blame her. Yet, she remarries within two months of his death. She also, by the way, is allied with Claudius throughout the play, far more often than she is allied with her son. Her marriage with Claudius seems to be dominated by sex, at least from Hamlet's point of view. This focuses her attention on her marriage, rather than on her role as mother.
The other female central to the action is Ophelia. Marriage is referenced early in the play when she is warned that Hamlet cannot be serious about pursuing a relationship with her, because she is not of noble blood. The idea is that Hamlet, a prince, would be expected to marry a person of royalty for political reasons.
Hamlet does appear to have loved Ophelia, however, but turns against her when she spies on him for her father and King Claudius. Hamlet berates and humiliates her, and uses her as she attempted to use him. Though Hamlet and Ophelia are not married, there is some evidence that Ophelia is pregnant with Hamlet's child, which specifically makes their relationship relevant to your question.
In short, marriage is a flawed institution in the play, due mostly to inherent weakness in the female gender.
In Hamlet, the institution of marriage is primarily represented as a social institution for elites. William Shakespeare examines it through the current marriage of Gertrude and Claudius and the previous marriage of Gertrude and the elder Hamlet. Because Denmark was a monarchy, the marital arrangements between the royals were crucial to the country’s current and future political stability. These arrangements included the monarchs’s reproduction, with the goal of producing male heirs. Largely because of the ongoing conflict with Norway, including the constant threat of invasion, Denmark is unstable.
Before the play begins, King Hamlet has died and Queen Gertrude is left a widow. As a female who had married in to the royal family, she could not rule alone. She primarily has two choices. One is to allow her son to ascend the throne, in which case she will no longer be queen. The other is to marry her late husband’s brother, who is a member of the royal family. The second path will allow her to remain queen; if she were to bear another child, she will have produced two viable heirs. William Shakespeare leaves open whether Gertrude is unaware that Claudius killed his brother or was complicit in his murder.
Claudius is portrayed as primarily motivated by ambition and greed. Killing his brother, King Hamlet, was just plain wrong. Because he was the second son, it was the only way he could become king. And because Gertrude has a son who is heir to the throne, he must marry her in order to rule legitimately. That is, he could not kill Gertrude along with Hamlet Senior, because then Hamlet Junior would have become king.
If you look further at marriage and specifics, you could argue that marriage is a flawed institution because it hasn't worked. While the queen was not divorced from her husband, she really had no idea what was going on in her marriage with King Hamlet. When Hamlet presses after killing Polonius, she acts as if she never even considered that her husband could have been murdered. Further, we never hear anything of Polonius's wife/Laertes and Ophelia's mother. She may have died, sure, but the key factor is Polonius's and Laertes comments to Ophelia, like dstuva says. There's a political element to their comments - that's what they're mostly about. But there's never any mention of the fact that maybe Ophelia does love Hamlet. It's simply out of the question.