A good question! Marcellus, a soldier in the employ of the State of Denmark, is on guard-duty on a platform outside the castle and asks the same question. Horatio eloquently provides the answer. I have quoted the most significant sections of his response below:
Our last king, ...
Was, as you know, by Fortinbras of Norway, ...
Dared to the combat; in which our valiant Hamlet--
Did slay this Fortinbras; who by a seal'd compact,
Well ratified by law and heraldry,
Did forfeit, with his life, all those his lands
Which he stood seized of, to the conqueror:...
Now, sir, youngFortinbras,
Of unimproved mettle hot and full,
Hath in the skirts of Norway here and there
Shark'd up a list of lawless resolutes, ...
to recover of us, by strong hand
And terms compulsatory, those foresaid lands
So by his father lost: and this, I take it,
Is the main motive of our preparations,
The source of this our watch and the chief head
Of this post-haste and romage in the land.
What Horatio is saying is that they are on watch for a possible invasion by the young, hot-headed and inexperienced prince Fortinbras, heir to the throne of Norway, who had put together a motley crew of mercenaries in order to reclaim, by violent means, property which had been fairly claimed by the now deceased King Hamlet, prince Hamlet's father, when he slew King Fortinbras in battle. The rules of combat dictate that the victor in battle is entitled to the properties of the vanquished (the so-called 'spoils of war') which is exactly what happened in this instance.
The young Fortinbras has seemingly ignored this essential aspect of war and now seeks revenge and wishes to get back what he believes is rightfully his. His illegal invasion is imminent and Denmark's troops have been put on high alert.
Fortinbras, the son of the king of Norway, has raised an army and is threatening to invade Denmark in order to get back land that his father lost to King Hamlet, Hamlet's father. Claudius alludes to this problem in his first speech, and sends two representatives to tell Fortinbras' uncle, who is actually Norway's head of state, to stop his nephew from invading Denmark. It is notable that the ghost of Hamlet's father is first seen wearing the same clothing he wore when he defeated Fortinbras' father. Thus, Marcellus is correct, "Something is rotten in the state of Denmark."