The three genders are found in all the oldest Indo-European languages we know (Latin, Greek, Sanskrit, Gothic, Old Irish, Old Church Slavonic, Old Norse) with the exception of Hittite.
Hittite had two genders; but the two were neuter and common, rather than masculine and feminine.
Some scholars believe that Hittite represents an earlier stage, and Indo-European acquired the feminine gender after it split off; others argue that Hittite lost the masculine-feminine distinction (as most varieties of Scandinavian and some of Dutch have done in recent times).
Either way, it is clear that the three-way distinction was ancient in Indo-European. Nevertheless, it has been lost independently in many places, usually by the neuter merging with the masculine (eg in Romance, Celtic, and many Indic languages), the feminine merging with the masculine (as in Scandinavian above), or grammatical gender being lost entirely (English and Farsi).
It is never easy (and often not possible) to answer "Why" questions about language, but one factor that is surely relevant is when sound changes cause different forms to fall together.
Consider, for example, Latin, where the distinction between many masculine and neuter nouns and adjectives in the singular is only in the final consonant or lack of one:
- O-stems (2nd declension)
- nominative singular -us (m) -um (n)
- accusative singular -um (m) -um (n)
- U-stems (4th declension)
- nominative singular -us (m) -u (n)
- accusative singular -um (m) -u (n)
All other cases in the singular are identical.
Since these final -s and -m were mostly lost in the Romance languages, any formal distinction between these masculine and neuter nouns in the singular disappeared. (The plural of neuters was more distinct, and must have been remodelled by analogy once the awareness of the distinction was disappearing).
But many feminine nouns and adjectives had their stem in -a (1st declension) which had different vowels in their endings in many cases, so remained more obviously different.