The curses of the tochacha [portion of rebuke] come upon Israel "because you didn't serve Hashem Elokeichem with joy and gladness of heart, and you will serve your enemies." (Devarim 28:47). It means seemingly that even though one serves Hashem, but it is without simcha (joy) and gladness of heart, then it draws down a punishment "and you will serve your enemies". But how can we understand this? Can the reason for this bitter punishment be because of a lack of joy alone?!
The explanation is that eveyone has committed some sin or other, and from this sin comes the punishment; However, regardless of that, if he will serve Hashem with joy (simcha shel mitzva) this joy is so powerful that it awakens joy Above (so to speak), and nullifies the judgements. This doesn't happen when "you didn't serve Hashem Elokeichem with joy, etc", which draws down the punishment for the sins.