Who ever encountered his work? Was his music played somewhere else in Europe, or only where he lived? What strata of society had any chance of coming into contact with his music? What might be the approximate number of people who encountered his music during his lifetime altogether?
According to Wikipedia:
From 1703 he was back in Thuringia, working as a musician for Protestant churches in Arnstadt and Mühlhausen and, for longer stretches of time, at courts in Weimar, where he expanded his organ repertory, and Köthen, where he was mostly engaged with chamber music. From 1723 he was employed as Thomaskantor (cantor at St. Thomas) in Leipzig. He composed music for the principal Lutheran churches of the city, and for its university's student ensemble Collegium Musicum. From 1726 he published some of his keyboard and organ music.
he was granted the title of court composer by his sovereign, Augustus, Elector of Saxony and King of Poland, in 1736. In the last decades of his life he reworked and extended many of his earlier compositions.
So, during his lifetime his work was played mostly in the churches and courts where he was employed primarily to play the organ. His composition was an optional extra. Over a roughly 50 year active span it is likely that a few tens of thousands of attendees at those churches and courts heard his music.
Despite being born in the same year as Handel about 130 km away they never met although Bach did make efforts to meet but Handel wasn't interested. His compositions didn't start to take off and gain recognition until almost 80 years after his death when Mendelssohn performed the St Matthew Passion in 1829.
Bach was also director of the Leipzig Collegium Musicum which gave weekly concerts at Café Zimmermann (in Leipzig, of course.) He also had big family reunions which were described as big parties. Lots of people likely heard his stuff here. He wasn't quite the unknown the Nineteenth Century liked to believe.
Contemporary reports (which are somewhere on the net but I can't find them quickly) from the Berliner Tagblatt call him "the Famous Bach" and mention how Bach put off visiting Frederick the Great for some years. (Kings didn't have as much power as one might have thought.)
Another important "audience" for Bach's music was his students. Many of his presently most studied and performed keyboard pieces were written for his children (such as in the Klavierbüchlein für Wilhelm Friedemann Bach) and at least one of his wives (the Notebook for Anna Magdalena Bach).1 Numerous small pieces, the Inventions and Sinfonia, the two volumes of The Well-Tempered Klavier, and The Art of Fugue (not specific to keyboard) were written either as teaching pieces or as compendiums of Bach's knowledge, intended for future generations. In some cases, copies of his pieces that were scripted either by Bach or a student are important source material for modern editions.
1 Not all of the pieces in these "Notebooks" were composed by Bach, nor were they all composed specifically for the notebooks. However, they do contain pieces composed by Bach specifically for the purpose of teaching.
Trying put an actual number on this would be absolute speculation. Even today with data for recording and concert ticket sales you would not be able to do more than make a super general estimate of listeners. I think you need to think about it in more general terms, the extent of Bach's influence during his lifetime, by looking at distribution of scores and performance audiences.
It's pretty well known that most of Bach's music was not published during his lifetime. However, hand written manuscripts of his music must be considered too. It seems his music was more widely distributed in hand written manuscripts that published score. The Wikipedia page List of compositions by Johann Sebastian Bach printed during his lifetime has a nice summary. Some highlights include:
- emphasis was on publishing keyboard works, which I think was practical matter, it's easier for people to use keyboard scores than orchestral and it's less costly to publish
- the market for Bach's music was small as most considered it too difficult and technical
Interestingly, The Well Tempered Clavier was not published during Bach's lifetime. Ironically, it may not have been published, because it had been so widely distributed in manuscript form there wouldn't have been a market for sales.
Regarding audiences it seems you can make a general division between church audiences and aristocratic connoisseurs and professional musicians.
In his early career Bach was a court musical director in Weimar and Kothen. Later Bach was the music director for several churches in Leipzig from 1723-1750. It's hard to say how many people would have heard Bach's music in these various positions. But one way to try to get a sense of the scope could be comparison to the size of cities and the composers worked in them. Gluck, Graun, and Telemann work in court or church positions in Vienna, Berlin, and Hamburg which are three of the largest German cities. Leipzig by comparison is about a half or quarter the size of those largest cities. Weimar isn't even on the linked list. I imagine the smaller size of those cities would have a direct impact on the number of people who heard Bach's music: smaller cities, smaller audiences.
That doesn't necessarily mean Bach's influence wasn't far reaching. Anecdotes and stories show Bach's reputation was great and surely many people must have heard his music for him to have gained that reputation. The keyboard "dual" between Bach and Marchand is an entertaining example. The Goldberg Variations were supposedly written at the request of an aristocrat. That story is apparently apocryphal, but the music was publish during Bach's lifetime. The story of Frederick the Great and Bach however is true and informative. Frederick had musical courts in Berlin and Potsdam and famously invited Bach to his court to improvise on a theme written by the king. After the meeting Bach wrote a composition on the theme, The Musical Offering, which is among the relatively small number of works published during Bach's lifetime. Command performances are a recognition of reputation. That reputation had to come from listeners.
I think the general historic view is Bach was well known and highly regarded as a keyboard player and composer, but his style was considered difficult and technical. He was known more to the smaller circle of aristocracy and musicians and not famous at the level of someone like Handel or Telemann. (If you're into rock music, I think it's like comparing Robert Fripp to Jimmie Hendrix or Eddie Van Halen. Lot's of people know the former, but he isn't super famous like the later.) In terms of social strata the church music would have been heard by a audience beyond the aristocracy, but I doubt if the general congregation knew who composed the music, and remember that music on the whole wasn't published. The number of people who heard Bach's music during his lifetime would certainly be comparatively small, but it seems wrong to mistake that for obscurity.
After Bach's death people strove to preserve his work. In 1829 a Bach revival started with Mendelssohn's production of the Saint Matthew Passion. That was the beginning of a reversal for Bach. Eventually Bach's music became known the world over while ironically many of his contemporaries who enjoyed great popularity are now obscure.