system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: Why do some languages have masculine and feminine nouns?

I'd like to understand both from a historical perspective, and also how it is decided for new words?

Being English I've found this the most difficult aspect of learning a new language such as Spanish.
gpt
It's important here to distinguish between grammatical gender and biological gender. Grammatical gender describes what rules a specific word follows in the grammar of that language. Biological gender describes living things that reproduce sexually by splitting in two separate genders. Despite the name the two aren't strictly related. 

Grammatical genders are more akin to word classes: words in the same class will behave in similar ways, such as declining and conjugating after similar rules, using similar adjectives when described in a sentence (i.e all blue masculine words in Icelandic are "blár", all blue feminine objects are "blá", all neuter blue things "blátt"), or take a specific determinate forms (i.e la vs le in french). 

So grammatical genders are a description of how a word behaves, not the other way around. 

>  Historical perspective

We frankly don't know for sure. Some theories suggest that genders initially started as classes to separate inanimate and animate objects, Later feminine and masculine split due signify a group of things, and words that didn't properly fit with the other two classes. 

There are some evidence that genders slightly increase comprehension and comprehension speed of a sentence, as well as slightly reducing ambiguity, but research seems to be situational. 

> How is it decided for new words.

By observing how people use the word. Remember: Gender isn't imposed from on high by an absolute authority.  it's a handy box that we use to group similar words together. If the new words is displaying characteristics of either gender we put it in that gender. People will morph new words so that they fit in with the grammar and don't sound stiff and unnatural, and during this morphing process people decide if the new word sounds better as masculine, feminine, or neuter (or other genders some languages might have).