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 thereShark'd up a list of lawless resolutes, (1.1.98)For food and diet, to some enterpriseThat hath a stomach in't; which is no other--As it doth well appear unto our state--But to recover of us, by strong handAnd terms compulsatory, those foresaid landsSo 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 headOf this post-haste and romage in the land.

Denmark is preparing for War in Act I, scene i, because of ongoing and previous wars between Denmark and Norway. King Hamlet of Denmark killed King Fortinbras of Norway taking his money and land. Prince Fortinbras is mad, and wants to take back everything Hamlet stole, and gain revenge. He has gathered a group of brute criminals who he plans on using to get revenge on Denmark