In Spanish, most of the nouns that end in -o are masculine; most of the nouns that end in -a are feminine. Write yourself out a list of the exceptions (there are quite a few - I maybe should have said ‘many’ instead of ‘most of’.), and take it from there. Some of them, the article changes based on the gender of the person doing that job - el taxista vs. la taxista, el barrista vs. la barrista, for example.
I spent a lot of time trying to sort out the inherent feminine, neuter or masculine nature of nouns with very little success. It was made worse by the fact that while nouns often retain their gender across different branches of linguistic families (Almost all the time, the French noun will be the same gender as the equivalent Italian noun, for instance.), nouns do not have the same gender across languages. French/Italian/Spanish words for ‘the sun’ are masculine; German uses die Sonne (feminine); the Russian word for the sun is neuter. Even within the same language, the same object may have more than one word, and those words are not necessarily the same gender. In French, la rivière (feminine) or le fleuve (masculine). (There is a semantic distinction between the two words - a fleuve flows into the ocean, while a rivière flows into a lake or another rivière or a fleuve.)
However, what saved me was speaking to a friend who was studying linguistics, and he told me that it’s better to think of it as something is ‘grammatically’ masculine, feminine, or neuter - they get called by these human gender terms because they also happen to function that way (most of the time) over human beings, and they’ve been back-formed to cover inanimate objects. In Russian, most of the masculine nouns end in -i, or a consonant; most of the feminine nouns end in -a or -ya; most of the neuter nouns end in -e or -o. In Italian and Spanish, most of the masculine nouns end in -o; most of the feminine nouns end in -a. In French, the patterns are not as easy to find. In German, there are a couple of patterns which are useful, but for the most part, you just have to memorize the gender, the plural, the dative case form, and the genitive case form when you learn the word.
I now think of them as left-hand, right-hand, and feet nouns. I will go so far as to write them on the bottom, right hand and left hand of the page. When I go through those word lists to study, I will speak the feet words to my feet, the right-hand words to my right hand, and the left-hand words to my left hand.
There are other useful learning aids - always learn a new noun with its article, so that they become associated in your mind. Doesn’t work as well for Italian words that begin with a vowel and don’t follow the -o masculine/-a feminine pattern. Doesn’t help you with the many words in French that begin with a vowel.
You can also learn a new noun with a variable adjective - la table verte versus le livre vert, for instance.
As to why gendered nouns happened in some languages - it happens because in some place at some time, it clarified something in the language, making it more expressive, less ambiguous, more cromulent… Once something like that catches on, it can take eons for it to evolve its way out of the language. I think of the ‘tones’ in various Asian languages - it disambiguates words that would otherwise be pronounced exactly the same. Ma, Ma, Ma, and Ma sound exactly alike; using the tones, you get mā (妈) – Mother; má (麻) – Numb; mǎ (马) – Horse; mà (骂) – Scold.
Oh, accents in Spanish - the accents are only rising from left to right; from French, I’m used to calling them ‘accent aigu’. á, é, í, ó, ú, ñ, and the occasional ü, and their capital letter equivalents. Unlike French and German, where they indicate a change of vowel sound, Spanish accents are there to tell you where the accented syllable is in the word. Spanish spelling rules are among the easiest for any human language. You’ll soon get used to hearing the word and just knowing if an accent is needed, and where the accent is supposed to go.
Hope this helps!