In Medieval music theory (main figure: Guido of Arezzo, basically the inventor of Western music notation), a melody was considered moving through hexachords. A hexachord is a subrange of 6 of the entire range of possible diatonic notes, with the intervals 1-1-½-1-1. There were 3 possible hexachords: naturale (CDE|FGA), durum (“hard”) (GAB|CDE) and molle (“soft”), that started on F, but had to have a flattened B to make the middle interval also a half step (FGA|bCD), in order to avoid the dreaded tritonus (augmented fourth), the diabolus in musica. Sometimes, the flat was not even notated, as an educated singer knew when the melody had wandered off from, say, hexachordum naturale to hexachordum molle. But in case this was ambiguous (or maybe because singers weren’t trusted to know their theory), however, a ‘round b’ (b rotundum) was used to indicate the low B, and a square b (b quadratum) indicated the high (non-flattened) B. Other names were ‘b durum’ and ‘b molle’. The square durum symbol happened to look like a Gothic (blackletter) h (𝔥), which is probably why that name stuck in the German-speaking world.
The durum symbol evolved into our natural sign ♮, and the b molle into our flat ♭, which the French and the rest of the romance-speaking world nowadays call bémol, bemolle etc. Dur and Moll have become the modern German words for major and minor keys.
More info e.g. here or here.