Denmark represented a strategic value. The Straits of Denmark pretty much controlled the traffic between the North and Baltic Seas. But it was also a stepping stone to Norway where Hitler could harbor his navy. He also needed Norway so his Luftwaffe could assist in the Battle of the Atlantic and be in a good position to conduct air raids on Britain.
Hitler's forces invaded Denmark on 9 April 1940. After just two hours of fighting, and sixteen Danish soldiers killed, the Danish government surrendered. Some say they should've put up a harder fight, others say because they couldn't win anyway, why bother? Perhaps a harder resistance could've given others, like Norway, more time to prepare.
Hitler allowed the king and government to remain in Denmark and keep on running the government with little interference. Hitler wanted to use Denmark as a model to demonstrate how good a Nazi controlled Europe would be. He even allowed Denmark to maintain a small army and navy.
On the surface, it looked as if the Danes were fine being under Nazi control. But underneath, the Danes weren't happy at all. They formed resistance groups which conducted various underground activities ranging from producing illegal publications to spying and sabotage. Workers went on meaningless strikes. The Danish military passed intelligence information to the Allies stationed in Sweden. When the Nazis began rounding up Jews, the locals countered by smuggling thousands of Jews to Sweden. And the Danish government always seemed to have a special knack in making simple little German demands almost impossible to execute.
Germany demanded new tough laws be passed and enforced. The Danish government flat out refused and on 29 August 1943, Germany dissolved the government and declared martial law. King Christian simply ignored this and continued to run his country throughout the war. Rather than turning over their naval ships to Germany, the Danish Navy scuttled 32 of their ships and snuck another 13 vessels to Sweden. Denmark's contribution to the war effort was small but these micro stories are quite exciting.
Denmark's biggest contribution to the war is found with her Commonwealth states; Greenland, Iceland and the Faroe Islands (about half way between Scotland and Iceland). Britain conducted pre-emptive invasions at the both Iceland and the Faroe Islands to keep the Germans from establishing bases there. Soon Iceland was turned over to the US, while they were still neutral. The Danish Ambassador to the United States signed an agreement allowing America to defend Greenland and establish military bases there. These Atlantic bases proved vital in winning the Battle of the Atlantic and provided a northern route for Allied planes flying to Britain.
Iceland had been self-governing since 1918 but were still under the Danish King. Given the political situations created during the war, Iceland took advantage of it and became officially independent in 1944 and have remained such ever since.
Right after the war, the US offered to buy Greenland from Denmark, but the Danes turned down the offer. Five years later as the Cold War progressed, they did agree to let the US build an air base there.