Devarim28:47

תַּחַת אֲשֶׁר לֹא־עָבַדְתָּ אֶת־יְהוָה אֱלֹהֶיךָ בְּשִׂמְחָה וּבְטוּב לֵבָב מֵרֹב כֹּל׃

Because you did not serve the Eternal your Almighty with joy and with gladness of heart, out of the abundance of everything,

Devarim 28:47

תַּחַת אֲשֶׁר לֹא־עָבַדְתָּ

Devarim / Deuteronomy 28:47 · Pshat

Devarim 28:47

תַּחַת אֲשֶׁר לֹא־עָבַדְתָּ אֶת־יְהוָה אֱלֹהֶיךָ בְּשִׂמְחָה וּבְטוּב לֵבָב מֵרֹב כֹּל׃

Because you did not serve the Eternal your Almighty with joy and with gladness of heart, out of the abundance of everything,

Pshat פְּשָׁט

Joy as a mitzvah

You can do what is needed honestly but with a heavy heart. Or you can do the very same thing with joy. Is there a difference if the result is the same?

Rashi: "out of the abundance of everything" means while you had every good thing. Rabbeinu Bahya: joy in doing a mitzvah is a mitzvah of its own, with a reward of its own. So the Torah punishes one who serves without joy.

How Rashi and Rabbeinu Bahya explain it

Rashi Out of the abundance of everything

While you had every good thing.

Rabbeinu Bahya Because you did not serve the Eternal your Almighty with joy

Scripture blames him for serving the Eternal while his service was without joy. For a person must rejoice when busy with mitzvot. Joy in doing a mitzvah is a mitzvah of its own: besides the reward for the mitzvah, there is a reward for the joy. So here the one who does a mitzvah without joy is punished. Therefore a person should do the mitzvot with joy and with full intent.

So they said in the midrash on Ruth: had Reuven (Reuben) known that the Holy One, blessed is He, would write of him "And Reuven heard and saved him from their hands" (Bereshit / Genesis 37:21), he would have carried him to his father on his shoulders. Had Aharon (Aaron) known that the Holy One, blessed is He, would write of him "and he will see you and rejoice in his heart" (Shemot / Exodus 4:14), he would have gone out to meet him with drums and dances. Had Boaz known that the Holy One, blessed is He, would write of him "and she ate, and was satisfied, and left over" (Rut / Ruth 2:14), he would have fed her fattened calves.

Takeaway

The verse stands among the curses: they will come "because you did not serve with joy". Rabbeinu Bahya draws the conclusion: joy is part of the mitzvah itself.
The midrash on Ruth (Ruth Rabbah 5:6) gives three examples of a good deed done halfway. Reuven saved Yosef (Joseph) from his brothers but did not bring him back to his father. Aharon rejoiced at meeting Moshe (Moses), but only in his heart. Boaz gave Ruth a handful of grain, not a feast.
The midrash's lesson: had a person known that his deed would be written down forever, he would have done it with full joy.