The Midrash (28:1) writes that the Chachamim wanted to put sefer Koheles in geniza because they thought it heretical ( modern books that have been banned by "gedolim" can consider themselves in good company!) Shlomo haMelech tells us, "Mah yisron l'adam b'chol amalo..." what good is all the toil of man. Can it be that Shlomo was suggesting that toil in Torah has no value?
The Chachamim reread the pasuk so that in fact it does give us a positive message. It doesn't say "amal" - toil; it says "amalo" - his [man's] toil. Toiling in the mundane affairs of man does not accomplish anything; toiling in G-ds Torah is worthwhile work. Koheles is giving is the right message.
Asks the Sefas Emes (5656): what was the hava amina of the Midrash? The thrust of sefer Koheles is that the secular world davka is "hevel havalom," but "sof davar ha'kol nishma..." yiras shamayim and Torah and mitzvos have real value. How can the Midrash even entertain the thought that Shlomo meant to suggest that ameilus in Torah is worthless?
If not for the Sefas Emes I would suggest that perhaps you can explain the Midrash using a vort that we've all heard said over at siyumim. In the hadran we say that "anu ameilim v'heim amelilim....," that we work and the non-Jews work, but while we get reward for our work, they don't. What does that mean -- don't even non-Jews get a salary for their work? The famous answer is that in the secular world, you get paid for the finished product. The labor is just a means to the end. In Torah, G-d rewards us even for the toil. You can spend the whole day trying to understand a hava amina that has no bearing on the final halacha and you still get credit for learning. Maybe the hava amina of the Midrash is that toil in Torah is no different than toil at any other occupation and it's only the final product -- what you come away with in the maskana -- that counts. "Amal," the work to get there, has no value. Kah mashma lan the Midrash that there is reward in Torah even for the ameilus, even for just the work, independent of the results.
But the Sefas Emes says a better pshat.
The parsha has a long section listing the chagim that opens with the introduction, "Eileh moadei Hashem... sheishes yamim tei'aseh melacha u'bayom ha'shevi'i Shabbos shabbason... (23:2-3) Some meforshim are bothered by the fact that the list of holidays begins with Shabbos, which is not a mo'ed. I don't know if that question will cause anyone to lose too much sleep because we sort of understand that there is a relationship between Shabbos and other holidays in that that all of them have kedushas zman. The whole question, however, is misplaced, because the list of holidays does not really begin with Shabbos. The list of holidays begins with "sheishes yamim tei'aseh melacha," work should be done on the six days that precede (or come after, depending on how you look at at) every Shabbos. The six work days of the week certainly have no kedusha, are not holidays, and would seem to have no place on the list. The real question is why begin the list of moadim with them?
On Yom Kippur we know that the kohen gadol has to dunk in the mikvah between every change of clothes, from gold to white and white to gold, etc. The Chasam Sofer last week in Acharei Mos writes that we understand that when the kohen gadol switches from gold garments to white so he can enter the kodesh kodashim, he is going into a holier place than normal, he will be doing avodah that is more special than normal, and so he has to go to mikveh to enter a higher state of purity. But why dunk again on the way out, to switch back to gold? That's a step down, not a step up?
The Chasam Sofer says a yesod: after the kohen has experienced the higher level he was at in the kodesh kodashim and comes out, those gold garments he changes into are not the same gold garments as before. Life is different now. It may look the same, it may fit the same, but it's not the same. The higher level the kohen was on sticks with him even as he returns to the gold garments that he wore before.
When a nazir completes his vow of nezirus, the Torah tells us, "achar yishteh ha'nazir ya'yin," afterwards the nazir can drink wine. Shem m'Shmuel asks: why does the Torah says "the nazir" can drink wine -- he is not a nazir anymore once his vow is up?! The answer is the same yesod the Chasam Sofer is telling us. The whole point of that period of abstinence is so that once the vow is complete, the person is still a nazir, he still retains his kedusha. He may be able to now drink wine, but he is not the same person as before.
Coming back to the parsha of the moadim, the Kozhiglover in Eretz Tzvi writes that the cycle of moadim is not about spending a week here and a week there in a state of holiness and the rest of the year in a different, secular world. The point of the parsha is that the week here and a week there we bask in revealed kedusha give us something to take with us and make part of the rest of our lives so that the six work days we come back to are different days than before. The same kedusha that we experienced in the mo'ed is still there afterwards, albeit in hidden form, albeit without generating an issur melacha, but it's part of our lives. "Sheishes yamim tei'aseh melacha..." is a mo'ed too.
Now the table is set for the Sefas Emes. Peshita that a guy sitting and learning is accomplishing, while someone working so he can buy himself a new car or gadget is wasting his time. There was never a hava amina otherwise. But what about the person who works as a doctor and treats the poor without charging -- is he he/she simply toiling for nothing? Is the person who spends a few hours helping a friend in need wasting his time with worthless work? That's what bothered Chazal.
Of course you get credit for poring over a Rashba in the beis medrash. But what the Midrash is telling us is that to take the Rashba out of the beis medrash, to bring G-d into everything you do, to find G-d in everything that you do, to make the "sheishes yamim..." holy too, that' takes real work. You can toil as a doctor, a plumber, a lawyer, and it can be "mah yisron l'adam b'kol amalo," or you can toil as a doctor, a plumber, a lawyer, and it can be ameilius of Torah and the highest value.