A couple of quotes:
The grammatical sense of the word is actually older (from the 14th century: it’s related to genre and genus, i.e. type, kind, origin) and the meaning was extended in the 15th century to the human phenomenon. For a while, this extension led to gender being used as a euphemism for “sex,” where both words could refer to social or biological differences, but starting in the 1960s, feminist writers began using gender to refer to the social distinction and sex to refer to the biological one, presumably to make it easier to talk about these two phenomena separately.
Incidentally, the conflation of the grammatical and natural meanings of gender is responsible for the confusion of English speakers learning a foreign language with a “gender system.” “What,” the learner inevitably remarks to themself, “is so darn male or female about plates and bowls anyway?” The answer is nothing.