Hamlet's decision to act mad, or to put on an "antic disposition," is a conscious choice that he makes, right after the ghost of his father reveals who murdered him. Claudius is capable of murder, and is obviously a very power-hungry guy, who was able to, at some level, woo his mother into a quick marriage also. So, Claudius is a guy who gets what he wants, even if the cost is murder. Hamlet is aware of this; he had his suspicions of his uncle even before his father confirmed them. Hamlet, knowing of his uncle's devious, cunning and dangerous nature, doesn't want his uncle to suspect that Hamlet knows anything. He goes so far as to make his buddies that have seen the ghost "swear" that they will never reveal what they have seen, so that even the tiniest whiff of what has been going on doesn't get out.
From this point on, Hamlet devises a plan. He wants to investigate his father's murder, but without arousing any suspicions. The castle is small though, and people are already watching him (he's been acting strange ever since his dad died, so people have their eye on him), so the only way to go about investigating without arousing suspicion is to pretend that he's mad. That way, if he gets too close to the truth, Claudius might must dismiss it, saying, "Eh--that's just Hamlet being crazy again. No need to be concerned." Hamlet's plan works for a while, until Polonius is killed. Then, the king's nervousness gets the most of him and he ships Hamlet off, with orders for his buddies to kill him.
So, whereas some of Hamlet's "madness" might be a reflection of some inner turmoil he is experiencing, it is also a purposeful ruse he is fronting in order to buy himself some time to investigate whether the ghost truly is truthful. He is trying to hide the fact that he knows Claudius killed his father. I hope that those thoughts help; good luck!