Nouns and Gender in Spanish

Why do nouns have gender in Spanish?   We can trace noun genders back…