Flags in the early times had the function of rallying people in battle and showing them where their side was fighting and heading. So many flags had a 'signal' color like red to draw attention. That is also why the Danish flag is red.
The white cross represents Christianity and can in similar form also be found in the flags of the other Scandinavian countries.
Legend has it that the Danish flag fell out of the sky as a sign of Heaven during the battle of Lyndanisse, in 1219.