Why do German nouns have a gender?

Why do nouns in German have a gender?   The simple answer is that in German, all nouns are assigned a gender, either masculine, feminine or neuter. There are some exceptions to this rule (e.g. certain foreign words), but for the most part, all German nouns have a gender. There is no real reason why …