Because there has been an ongoing war with Fortinbras, the Norwegian prince, who is determined to add Demark to his cadre of conquered nations. Fortinbras has a grudge against Denmark, as King Hamlet of Denmark had previously acquired, justifiably, in war, some of Norway's land. The Danes, knowing Fortnibras is unlikely to take his defeat diplomatically, prepares for retribution.
Here is a portion of the scene in Fortinbras' motives are elucidated, explained by Hamlet's friend, Horatio:
Now, sir, young Fortinbras, (1.1.95)
Of unimproved mettle hot and full,
Hath in the skirts of Norway here and there
Shark'd up a list of lawless resolutes, (1.1.98)
For food and diet, to some enterprise
That hath a stomach in't; which is no other--
As it doth well appear unto our state--
But 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.