Irregularity. It was probably regular back in the times of Proto-Germanic (Danish gets it from Old Norse). You find it also in Icelandic (conservative as it is). Funny enough Norwegian Nynorsk has it... but not Bokmål (which is closer to written Danish)! Now, if there's a pattern to look for those things, it's lost to me, and most probably wouldn't be of any use without a PhD in comparative linguistics.
English has this kind of things, too (mainly on verbs - look up "ablaut"), and it drives us non-native speakers crazy :-D
there is a historical reason, but the explanation would probably seem very complicated to anyone not interested in linguistics. It's quite common in all Germanic languages and it is called "metaphony". It will probably be best to learn it as an irregular noun, just like English "foot", "goose", "man", etc.
It's quite a common phenomenon, there are examples even in the varieties of romance spoken in northern Italy. Languages around the whole world tend to modify sounds according to context and metaphony in just one of the ways they do that. In Germanic is really common but I expect many other languages to have it. But, as I said, it's complicated for those without a linguistic background. For them it is usually better to learn the "exceptions" by heart.