Our Gemara on Amud Aleph discusses a scenario where a person makes an oath to not benefit from the person, is forbidden from benefiting from any of the community property. Included in this community property is the Shul and the scrolls (what we would call books, but they didn’t have books or codexes in those days.) 

The commentaries raise a question as to why it would be forbidden to benefit from the Shul or the Sefarim as there is a principle that מצות

לאו להנות ניתנו The commandments were not given to derive benefit. For example, one might be able to hear a Shofar blowing from

a person whom he made a vow forbidding receiving benefit, and even from a shofar that he made a vow forbidding benefit from (Rosh Hashanah 28a.) Different answers are given, but today we will not focus on the lomdus of these answers but instead on the concept itself of מצות

לאו להנות ניתנו The commandments were not given to derive benefit.

The Maharal (Tiferes Yisrael 6) raises a question. If this principle is true, how to write reconcile what is stated in Devarim (6:24):

וַיְצַוֵּ֣נוּ ה׳ לַעֲשׂוֹת֙ אֶת־כׇּל־הַחֻקִּ֣ים הָאֵ֔לֶּה לְיִרְאָ֖ה אֶת ה׳ אלוקינו לְט֥וֹב לָ֙נוּ֙ כׇּל־הַיָּמִ֔ים לְחַיֹּתֵ֖נוּ כְּהַיּ֥וֹם הַזֶּֽה

Then Hashem commanded us to observe all these laws, to revere our God Hashem for our lasting good and for our survival, as is now the case. 

This certainly sounds like the commandments are meant to give us pleasure.

Maharal gives an answer that requires some contemplation. He says, that in truth, everything in the Torah is for our benefit. However, we are still nonetheless commanded to do so — and even the benefit itself is something we are commanded to receive. 

I believe he is saying, in some way, because everything God does is imperative, that is everything he does is authentic and truthful, from God‘s perspective there is little difference between a commandment and what is good and right. Therefore, commandments are an imperative and also bring benefit, and that benefit itself is imperative. But from the human vantage point, since they are principally commands even if they also bring benefit, that is not the focus and not under the rubric of what is forbidden, since it is an incidental pleasure. 

A different answer occurs to me than that of the Maharal. There is a difference between pleasure and benefit. Some things are hard to do and they are not pleasurable, but they are beneficial. And there’s a certain irony to the fact that humans like challenges and even find a certain kind of pleasure in painful hard work, depending on how they frame it. For example physical sensations such as rapid heartbeat, elevated body temperature and aches and pains without any context would probably be experienced as an illness such as the flu. Yet somebody who does a 5 mile run every day, or a bodybuilder, probably experiences the same sensations even though they feel great about what they’re doing. Regardless, it is clear that benefit and ultimate good is not the same thing as pleasure. Therefore we can say that the good that comes from Torah observance is not a direct pleasure and therefore not forbidden by oath.