Act I of Hamlet serves to establish the situation in Denmark after the death of the former King Hamlet. Young Hamlet is in deep mourning and his mother, the queen Gertrude, has quickly remarried the king's brother, Claudius, who has also ascended the throne. Hamlet is rightly upset by all of these events, and his state of mind is made worse when he sees and talks to the ghost of his dead father who reveals that it was Claudius who murdered him. One of the last pieces of information we learn in Act 1 is that Hamlet intends to "put an antic disposition on," meaning that he intends toact crazy. The reader is left wondering why he plans to do this, but it becomes clear in Act 2 that he hopes to be able to catch Claudius saying something or doing something that will reveal his guilt so that Hamlet can have actual proof of his guilt; he would never avenge the murder without proof.
He represents his madness in several ways:
1. He dresses in a messy style that Ophelia recognizes as radically not typical of him.
2. He goes to visit Ophelia, but he doesn't actually talk to her, he just stares at her in an unusual way.
3. When at court, he acts as though he doesn't know people whom he absolutely does know. He tells Polonius, Ophelia's father, that he is a fishmonger (when clearly he knows that he is courtier.)
4. In conversation with Polonius he talks in circles and riddles about "honest men" "conception" and "kissing carrion."
5. He responds to all comments directed at him in an overly literal way.
When he is with Rosencrantz and Guildenstern he continues to do many of the same things as above. He does this because he doesn't trust them. We can understand what he means by his comments, but the truth is lost on the two friends.
When he is with the court before the presentation of the play he speaks boldly and with a certain bawdiness that would be unbecoming of a prince. He acts as if there is nothing at all to worry about in the contents of the play and like he doesn't have a care in the world, even though he hopes that the play will reveal Claudius's guilt.
In Act 4, after he kills Polonius, he acts as if the murder didn't even touch his conscience and makes jokes about where body is stowed and about the king himself. He acts and speaks in a way that no good prince would dare to do.
By acting so not like himself, he able to keep everyone at bay and guessing about what is going on with him so that no one will easier suspect that he knows the whole truth and plans to actions against Claudius in order to avenge his father's death.