When Hamlet talks with the Ghost (his dead father) in Act I scene v, he is told about the foul murder committed by the King's brother, Claudius. This confirms Hamlet's gut feeling that something just wasn't right, and it's the speech which compels him to seek nothing but his father's revenge for the rest of the play.
In the midst of the telling, though, the Ghost tells Hamlet:
But howsomever thou pursues this act,
Taint not thy mind, nor let thy soul contrive
Against thy mother aught. Leave her to heaven
and to those thorns that in her bosom lodge
to prick and sting her.
In other words, leave your mother out of any plan to seek revenge. In the scene you mention, Hamlet is doing just what his father's ghost asked him not to do. The Ghost is there to remind him of that request, of course. Primarily, though, the ghost appears to re-inspire Hamlet in his plans for revenge.
Do not forget. This visitation
Is but to whet thy almost blunted purpose.
So Hamlet is being "scolded" by the Ghost for taking any of this out Gertrude and for having lost his focus on the goal--avenging his death by killing Claudius.
The Ghost, Hamlet's father Hamlet, is not happy at all about the fact that Hamlet is giving his mother such a hard time about the murder and about her subsequent marriage to Claudius. He made it pretty clear not to do anything to hurt her as he felt that her own guilt would be punishment enough, but Hamlet gets carried away and pushes Gertrude pretty hard about the whole affair.
So Hamlet Sr. feels he really ought to say something to his boy to get him back in line and it is also likely due in part to the very tender feelings the Ghost had for Gertrude and he doesn't enjoy seeing her in pain anymore than he wants to be dead!
The ghost reminds Hamlet to concentrate on Claudius - he is the person whom Hamlet needs to avenge - the ghost says that Gertrude is innocent, so Hamlet is not to punish her.