Further Analysis
Davïd's answer gives a good statement about the verse, providing a very useful analysis. However, there are a couple of points of analysis for Eccl 3:1-8 that I believe are relevant, yet unexplored (likely both by Davïd and the commentaries he references).
Four More Relevant Observations
"More," because again, Davïd's observations are very relevant.
The general truth nature of the other statements as opposites. This is not the case for most of the common solutions to this verse.
In seeking to figure out what is referred to, the commentators tend to be very specific in focus: sexual abstinence/engagement of a human man toward woman, casting/gathering stones into a field, breaking/construction of homes or buildings.
But in v.2, all living creatures can be born and die, all plants can be planted or plucked up. For v.3, all living things can be killed or healed, while a variety of things are composed of parts and can be broken or built-up (and as a side note, houses of stone already fall under this category). A wide variety of experiences can cause one to weep or laugh, mourn or dance as v.4 notes, and also for v.5b to embrace or refrain. In v.6, any thing that can be possessed one can gain or lose, keep or throw away. For v.7, all fabric can be torn or sewn,1 all thoughts can be kept to oneself or expressed. Then in v.8, one can love or hate a variety of things, and any group can be at war or peace with another.
So seeking too specific of a reference appears to be travelling down the wrong path. The economic idea (noted in Davïd's answer) at least has a general idea behind it, but is weak in that it is directed through a specific direct object of economy (precious stones), whereas economics could be expressed much more generally, and really is probably part of the basis of v.6 anyway. This leads to the second observation.
Each set of couplets are believed to relate to each other. There are fairly obvious parallels in v.2 to birth/death of animals/plants, v.3 to destruction/maintenance of living/constructed things, v.4 expressions of sorrow/joy, v.5 we will skip for now since it is the topic verse (but it can be noted that this relationship of the pairs is what drives the sexual union interpretation, as it is the only generally offered interpretation that relates 5a and 5b thematically), v.6 to having/not having possessions.
In v.7 the parallel is by far more obscure. Yet commentators believe, because others relate, this pair of couplets does. One view worth noting parallels to v.4, in that v.7 expresses activities one does when in sorrow of loss (tearing clothes and keeping silent), while the other paired activities are done when one is not sorrowing (sewing and conversing).2
For v.8, there is a parallel also, one dealing with human relations specifically, as people make war with those they hate and peace with those they love. But v.8 has a distinction that is the next observation.
Parallel pattern of paired couplets breaks. Barring perhaps v.5 that is under discussion, v.8 is the only pair of couplets to offer the parallel items in opposing order. That is, it is not love > hate, peace > war (or vice versa), where love/peace is first and their opposites stated last (an order of A B A B). Rather, they are given in a small chiastic structure of thought, love > hate, war, peace (and order of A B B A). The questions this evokes for v.5 are which order does it take and why? One final observation is the relation of v.8 to v.1.
Bookends of control. One is in no control of one's own birth, and little control over one's own death (v.1; suicide perhaps an exception, although there are failed attempts that as well). Likewise, one is in little to no control of whether one's people are at war or peace with another people. Not only is war/peace a decision based upon a group rather than just any particular individual, it is also based upon that other group's attitude. All the other couplets involve feelings, decisions, actions, etc. that are individually controlled. How, if at all, does this group vs. individual observation relate to v.5?
Another Possible Answer
Given the observations noted by Davïd (specifically the peculiarity of a direct object in this couplet of v.5a only and the negating verbs of the passage rather than antonyms) along with the above observations, and those observations joined with analysis from some other texts of Scripture, I find the most probable idea of v.5a is that of judgment versus fellowship, or perhaps more broad still, exclusion versus connection, specifically in community (group) context.
First, the specific direct object of "stones" must be relevant to the general truth trying to be expressed. Here's where an analysis of Scripture becomes useful, especially in conjunction with the verbs used. Every other "stone" (אֶ֫בֶן) reference used in conjunction with the verb שׁלך (to throw) is in a context of judgment being enacted:
- Lev 14:40, Priests were to cast out stones from a building infected with plague outside the city.
- Dt 9:17, Moses throws the tablets, made of stone (v.10), to break them as judgment upon Israel's sin.
- Josh 10:11, God casts hailstones ("hail" is inferred in some translations, the word is just "stones") from the sky against the enemies of Israel.
- 2 Kg 3:25, people throw stones in the fields around the cities as judgment upon those communities.
- Zech 5:8, a stone is thrown onto the basket to cover wickedness.
Another passage does not use the word אֶ֫בֶן, but carries the same concept:
As well, the casting of stones in judgment is very much a part of the Mosaic Law in the places where people were to be stoned to death. Passages indicating that as well as those that historically show it occurring would be relevant. In those passages, the word אֶ֫בֶן is found, but the verb used (רגם) is more specific to the act of stoning, and yet no one can argue that conceptually, the verb still carries the synonymous idea of שׁלך with respect to stones (that is, throwing of stones upon people in judgment). The verses relating to this verb with stones: Lev 20:2, 27; 24: 14, 16, 23; Num 14:10; 15:35-36; Dt 21:21; Josh 7:25; 1 Kg 12:18; 2 Chr 10:18; 24:21; Ezek 16:40; 23:47. Related to this, to a lesser degree (i.e. not a judicial act of stoning to death), is Shimeiah's throwing (סקל) stones upon King David (2 Sam 16:6, 13).
The above points to an overwhelming amount of evidence that throwing of stones is related to the general truth of enacting judgment. What of the gathering of stones?
The verb כנס (to gather) is not related to the direct object of stone elsewhere in Scripture. However, other verbs or contexts do refer to stones.
- Gen 31:46, Jacob command stones be taken (לקח) and made a heap (גַּל; i.e., gathered) upon which he and Laban and their relatives ate. In this case, after this "fellowship" time, the heap became a witness of possible judgment should one pass into the domain of the other (i.e., it was a truce, but with a threat of judgment behind it).
- Lev 14:42, a priest commands stones to be built back into the building that they were thrown out of because of plague (that is, the opposite of 14:40 given above for judgment).
- Josh 4:3 and 5, Joshua commands 12 men of Israel to put 12 stones together in the bed of the Jordan river; these 12 men were one from each tribe, showing that the gathering of the stones was in part a symbol of connection and fellowship of the tribes in this work of crossing into the promised land.
- Josh 10:18, Joshua commanded stones (plural) be rolled (גלל) together (i.e. gathered) over the mouth of the cave, to keep the five kings inside from escaping Israel (and does so again to bury their corpses after judgment, v.27). This act kept the kings "connected" to Israel long enough to deal with them.
- 1 Kg 18:31-32, Elijah takes stones and builds an altar (i.e., gathers) to offer sacrifice to God and bring the people back together in a belief of God. Altars were built of stone, and others represented connection, or more specifically fellowship (usually with one's deity, but also a place for community worship of that deity; but some altars were witnesses for the community fellowship only, e.g. Josh 22:10-11).
So the pictures in Scripture of gathering of stones show some idea of making and keeping connection, usually fellowship, though in the case of the five kings shut up by Joshua, it was simply to keep them connected to Israel for judgment. That verse, however, is of a decidedly different nature, and so may not really inform about the picture of gathering of stones as the others do.
If the ideas of judgment/exclusion and fellowship/connection are correct for Eccl 3:5, then how does that fit with the other observations?
Second, viewing as the general truth of a time for judgment/exclusion and fellowship/connection, its pairing with embrace and shun/remove/refrain/withdraw (רחק) makes them have a topical relationship as the other pairs of couplets (and a better one, I think, than the sexual union topical relation).
Third, viewing as the general truth of a time for judgment/exclusion and fellowship/connection, it makes v.5a a statement of group function, only marginally in the control of individuals, much like v.1a birth/death and v.8b war and peace, the bookends of the passage. This is significant in that v.5 rests as the middle pair of couplets, between the bookends, and is paired with the embrace/shun, that is a very individual idea. So the verse links the individual and the group concepts from the passage.
Fourth, the central location of the passage also takes on the chiastic structure of v.8, only reversed: exclude (cast)/connect(gather) connect(embrace)/exclude(shun) (B A A B) versus connect(love)/exclude(hate) exclude(war)/connect(peace). Note as well the topical relation of v.5 to v.8 in that sense.
Conclusion
The evidence suggests, to me, that many commentators have missed out on finding the general truth, the reason for the direct object, the proper topical relation between the middle pair of couplets, and other connecting observations. Primarily, they have missed it because they were seeking too specific of a reference, rather than what Scripture shows to be a more general view of meaning behind throwing versus gathering of stones.
A most likely candidate for the meaning is this idea of judgment/exclusion and fellowship/connection.3
NOTES
1 Fabric (or clothing) can be related to the idea of v.3 in breaking and building, but the specific reference here is distinct on two grounds. One, fabric/garments can be made from a single piece of thread, so it is not strictly "built" in the normal sense. Knitting and crocheting often involve just a single strand being wrapped around itself. Two, see footnote 2 for the particular purpose of the reference here.
2 This connection of tearing fabric and silence during sorrowing is noted by such commentators as Robert Jamieson, A. R. Fausset, and David Brown, Commentary Critical and Explanatory on the Whole Bible (1871; Oak Harbor, WA: Logos Research Systems, Inc., 1997); John Peter Lange, Philip Schaff, Otto Zöckler, Tayler Lewis, and William Wells, A Commentary on the Holy Scriptures: Ecclesiastes (1870; Bellingham, WA: Logos Bible Software, 2008); Duane A. Garrett, Proverbs, Ecclesiastes, Song of Songs, vol. 14, The New American Commentary (Nashville: Broadman & Holman Publishers, 1993).
3 Which idea is related to another answer here that notes divergence/convergence, only that answer approaches the text from a decidedly philosophical bent and lacks much strong Scriptural support or immediate grammatical analysis as this answer has attempted to provide here. Nevertheless, the conclusion of meaning seems related at least to the idea, primarily because the verbal points of the verse do indicate the idea of diverge/converge or exclude/include, which themselves relate to judgment and fellowship.