There are a lot of questions packed into your comment, which would need to be addressed separately.
Gender marking in articles is generally a sort of historical accident that evolves over time, probably originally from separate words such as pronouns, then collapsing into adjective forms, then demonstratives, and finally articles. During that time, though, the system can generalize and regularize so that it becomes a real active part of the grammar, as opposed to just another historical accident in forms.
As for classification, this is a major topic in Cognitive Linguistics, and the go-to reference would be:
https://en.wikipedia.org/wiki/Women,_Fire,_and_Dangerous_ThingsThere's been a lot more research since then, but you could start there. Lots of interesting "gender" (noun class) systems are found in the world's languages, sometimes not distinguishing sex at all. For example, Bantu languages just have "animate" as one noun class, along with about a dozen or so other categories based on various other properties of objects. More broadly there are connections to noun classifiers as in Chinese, etc.
As for your question about inanimate objects being classified as one gender or another, it's complicated. The older Indo-European system was a three-way contrast between masculine, feminine and neuter, but many inanimate objects were part of the masculine or feminine genders, not just neuter. (It is hypothesized that early Proto-Indo-European gender was split into animate vs. inanimate, not masculine/feminine at all.) The reasons for a particular inanimate noun being classified as masculine or feminine are varied. Sometimes it's by simple analogy based on the form of the word (e.g. endings in -a are typically feminine) or by semantic analogy to another word. Whether this all goes back to more direct cultural associations is an interesting question. On the one hand, different European languages today vary quite a bit in gender for many words, so there is at least a lot of shifting going on, even if they do go back to the some more direct system. On the other hand, a friend of mine did fairly well connecting his interest in mythology to arbitrary associations for particular words to memorize the gender of nouns in a German class, but I think that may have just been more of a strategy for memorization, based on arbitrary associations he came up with, rather than any deeper "truth" to what the words really mean (because you can imagine various explanations, for either gender, for the same words). Sometimes there do seem to be some patterns, so gender assignment isn't random, but it is conventional. Still arbitrary, but sometimes motivated, although not predictable. Other times there isn't much motivation at all, just various layers of historical analogy.