Anyone off the street could name several kings, religious figures, warriors, poets, philosophers, and other famous people from countless cultures and time periods, but if you ask them to name a famous musician from history, they'll all say "uhhh... Beethoven?", and will be unable to think of any others. Why is this? Why do the names of only 18th century European composers roll off of the average person's tongue when it comes to the history of music? Why can't he name an ancient Greek or Chinese musician or something?
Why can't he name an ancient Greek or Chinese musician or something?
Well, they might recognize names like Pythagoras or St. Augustine, but they aren't likely to be familiar with their musical thought. A simple answer to this particular part of your question is that musical compositions (much less biographical knowledge of musicians themselves) from that era just don't survive in a form that's anywhere near as complete as we'd like it to be. We don't even really have a good idea about how the very few compositions that survive from Classical Greece (or any other ancient civilization) are even supposed to sound (see here for an example how we pretry much have to throw up our hands at some point about what it's supposed to sound like)! That's a pretty big barrier to making ancient music common knowledge!
But I think this isn't really addressing the full extent of your question, so let me pontificate some more.
I think the reason why people like Socrates and Attilla the Hun are household names is because they are figures of general historical import, the kinds of names you are likely to encounter in many basic grade school historical educations. These are people that had a dramatic impact on the very shape of human civilization (whether in actual fact, as with Atilla, or more through their legendary status transmitted through the voice of their students like Socrates was through Plato). Few musicians (none, I'd say) can claim to have impacted western civilization to the degree and extent that a Henry VIII or a Napoleon did. All that is to say, artists in general get short shrift compared to rulers, powerful generals, and, to a certain extent, prominent intellectuals.
Rather than compare Musicians to historical figures writ large, I'd invite you to compare musicians to other kinds of artists: painters, poets, playwrites, etc. How many Average Joe English speakers can name a prominent playwrite who isn't Shakespeare? Tennessee Williams maybe, Sophocles or Euripides if they really know their stuff. But are they gonna know Racine? Goethe? Goldoni? Not likely. What sculptors could they name? Painters admittedly fare better as far as general knowledge goes.
We are still left with the question of why the late eighteenth century, but that it is such a circumscribed range is not that surprising when we consider that most of the household painter names are likely either Italian Renaissance painters or French Impressionists. It just so happens that our circumscribed range for music is German musicians working in the eighteenth century.
But why the eighteenth century? Well, the basic answer is that that's the point in time when a dramatic shift occurred in the way we frame the musical artist. We stop viewing them as a courtly servant producing functional and contingent music based on the particular needs of their employer, and we begin to view them as independent artists producing masterworks that stand the test of time and are tied to no individual circumstance (unless that circumstance is the artist's supreme vision at the moment of the artistic creation). Largely this is a narrative formed in response to Beethoven's music, what Scott Burnham has called the "Beethoven Hero" narrative, and is intimately tied to the rise of romanticism following the French Revolution. But it's something we've then projected back onto earlier composers, especially Mozart (see Amadeus) and Bach. As for why all (most) the household names are basically German, well, that's a question that has been asked before. Here was my response to one of those questions, which was followed by a useful discussion with /u/euzof