Why do Greek, Latin, French, German, Russian etc. have masculine and feminine gender for inanimate objects?
The history of Indo-European gender, like the history of any language feature, is messy. The mainstream theory is that the feminine, in fact, was originally not animate at all, but came from the abstract and collective suffix *-h₂. You may be more familiar with the Greek form of that suffix: -(i)a.
Why does gender not align nicely with animacy, let alone sex? Because of analogy, and cognitive patterning: making up classes of things, and then lumping everything in the world into one of them, by family resemblance. The mechanism for this lumping is Conceptual metaphor.
We see this more obviously in non-Indo-European languages, which have a lot more “genders”. (In fact, by the time you get to a dozen of them, there’s no point calling them genders, and we call them noun classes instead.)
The pioneering work on the kinds of cognitive categories underlying noun classes is George Lakoff’s. His acknowledged classic takes its title from the membership of one of the noun classes of Dyirbal language, an Australian Aboriginal language.
The noun classes of Dyirbal are:
Lakoff’s classic was thus titled: Women, Fire, and Dangerous Things.
Mind blown, Dimitra (who A2A’d)?
Greeks’ minds will be blown be the fact that πῦρ, γυνή, καὶ θάλασσα, “fire, woman, and the sea”, have been lumped together in an Ancient Greek maxim. (It has been attributed to Aesop: Πῦρ γυνὴ καὶ θάλασσα, δυνατὰ τρία, “Fire woman and the sea, these are the three strong things.” And Menander: Θάλασσα καὶ πῦρ καὶ γυνὴ τρίτον κακόν “Sea and fire, and woman is the third evil.”)
My mind is blown (though it shouldn’t be) by the fact that Lakoff had no idea about the Greek maxim when he wrote the book.