"La casa nueva comprada por mi hermano" has all the as to link them syntactically. Some languages have no grammatical gender--they indicate sex by use of the appropriate word (and often plural and even tense by additional words, sort of like the mangled 'man them eat yesterday burger many'). As my Hungarian barber said, "Why do I give a damn about the sex of my neighbor's dog?"
Note some languages are fine with disposing of plurals unless absolutely required. And there's a flock that don't need tense very much.
That "gender" overlaps with "female" creatures--human or animal--and any associated traits is entirely a knock-on phenomenon. If your language says an X is feminine, your neighbor's says it's masculine, and your other neighbor's has no gender, it's statistically likely that X will be judged more feminine/masculine/meh, respectively, esp. given priming or pronoun usage (but not very likely at all, and that mostly in forced and questionable studies or by researchers who really want to believe).
Latin also had a neuter gender, but eunuchs weren't neuter. Hungarians have no gender, but still distinguish men from women when it matters.In fact, Latinists don't call the 'genders' masc., fem., neut. etc., these days. Mostly they assign them roman numerals--Class I, II, etc. (Hellenicists in my experience go with gender more often, but maybe I'm just out of touch and using older or older-influenced sources.)
But Indo-European had a nice three way split, and the endings for female folk and a certain agreement class ended in -aH-, those in another class ended in -oH-. So PIE bequeathed the current split.
Note that there are weirdnesses. In Slavic, collectives 'look' feminine: one brat, "brother masc. sing.", but if you talk about a bunch of guys 'brothers' becomes brat'ya (which may be fem. sg. or treated as a semantic plural) or even colloquially bratva. This extends throughout Slavicdom, from Macedonian through Kashubian. I've seen it assumed that this meant that men were judged as individuals, women as part of a collective (so the pronouns mirrored how to handle one v many, not the other way 'round). My take is that they may have been different suffixes in pre-PIE and they merged in ways that speakers found tolerable. It happens. Nobody voted to have the past tense of 'wend" made the past tense of "go". Took a while for English to replace the "regular" plural of "cow" 'kine' with "cows." (Yes, one cow, many kine.)
Other languages have 20, 30 "genders", but none of them correspond to latest views on that topic. Because they're agreement classes.
Sometimes the agreement class extends to things that aren't nominals--nouns and adjectives or adjectival things. Slavic had a past tense form that was sort of like "is risen" or "is come" (a bit archaic for English, but extant in the 1600s and early 1700s)--a form of 'to be' + a participle in -l (called an l-participle, go figure). That's modern Russian past tense, "I understand, I 'got 'it' " ya ponimayu, ya ponyal" if you're male, ya ponimayu, ya ponyala if you're female, ya ponimayu, ya ponyalo if you're something that's grammatically neuter (that sounds really forced), and there are plurals forms, too.
Other Slavic languages had and still preserve a distinction between neuter and feminine and masculine in the plural, not that they're street-level language (unless you're parodying your professor or want to be beaten up).