The dictionary entry for farmers market shows three variant forms: farmers market, farmer’s market, and farmers’ market. You're likely to encounter any one of these stylings in your travels for fresh, locally grown produce—or perhaps even all three.
The apostrophe is one of the more beguiling punctuation marks, so much so that the British have a term (one appropriate for this article) for such a mark erroneously inserted: the greengrocer's apostrophe, predicated on the notion that a produce vendor’s handmade sign is likely to have an apostrophe where a simple plural is called for (e.g., radish’s rather than radishes).
The apostrophe, of course, is used to indicate a possessive. Which leads to the question of whether an apostrophe in farmers market is appropriate. A look at published use will find substantial evidence for all three:
Which probably accounted for the dual pangs of relief and guilt she felt when Oliver's number popped up on her phone while she was grocery shopping at the Saturday farmers' market.
— Sana Krasikov, The New Yorker, 27 Aug. 2018I used a mixture of crimini, white and shiitake mushrooms, although you could use whatever looks best at the store or farmers market.
— Cheri Swoboda, The Oregonian, 8 Nov. 2005Whenever something was going on in Beacon, Pete was there. The Hat Parade, the Spirit of Beacon day, the farmer's market--Pete was always there.
— Brendan Tween, Gothamist, 30 Jan. 2014
There are two questions that need to be asked. First, do we think of the market as belonging to the farmers, or merely as being associated with them? Second, if we do think of the market as belonging to the farmers (thereby encouraging a possessive construction), do we use the singular or plural possessive?
One way to answer the first question is to look at similar phrases. Doctor’s office tends to include the apostrophe consistently, which makes sense if you think of the office is a business that belongs to the doctor. (If more than one doctor shared the business, you could write doctors’ office).
Style guides try to make a distinction between possessive phrases and those that are merely descriptive. Since a farmers market is a place where farmers convene, but that does not necessarily belong to the farmers, many style guides recommend eliminating the apostrophe and simply treating the plural noun as a modifier: farmers market, a market for farmers.
You can think of similar phrases that imply a certain relationship between a thing and the people associated with it. Writers conference, teachers strike, or couples dance would seem to suggest a similar descriptive dynamic as farmers market, whereas renter’s insurance (insurance purchased by a renter) and teachers’ lounge (the lounge set aside for teachers) would hint toward a possessive.
As for farmers market, if you do consider the phrase to be possessive, you then need to ask whether the market “belongs” to one farmer or many farmers. If it’s one farmer selling goods, you can append a simple apostrophe-s to farmer, but if many farmers are coming together for the purpose, you’d be within your rights to style it farmers’ market.