This line, one of the most famous from Shakespeare's "Hamlet," appears in Act I, Scene 4.
In this scene, Hamlet has just seen the ghost and has followed it off the stage.
Marcellus, along with Horatio, has tried to get Hamlet not to follow the ghost but Hamlet has done it anyway.
Marcellus says that something is rotten in Denmark, meaning that he does not trust that all is well -- that he thinks something is wrong. He says this because he doesn't really think it's natural for a ghost to be appearing and talking to the prince and that the appearances of the ghost are a manifestation of something evil.