We may say “ivdu es Hashem b’simcha” (“serve God with joy” - Psalms 100:2) and “mitzvah gedolah lihiyos b’simcha tamid” (“it is a great mitzvah to always be happy” – Rabbi Nachman of Breslov) but there is a special mitzvah for us to rejoice on the three Festivals of Pesach, Succos and Shavuos.
Of course, there's a definition to "rejoicing," so we're not left on our own to ad-lib what it might entail. First and foremost, we rejoice by offering a korban shelamim (“peace offering”) at the Temple. Next, it means to eat meat, to drink wine, to wear new clothes and other things that we now naturally associate with a Yom Tov spirit. (If you’re a vegetarian and eating meat is not a pleasurable experience for you, consult your rabbi.) A person should likewise strive to ensure the happiness of his family members on Yom Tov. Finally, we should remember to facilitate rejoicing among the poor, travelers away from home, and converts (who do not have Jewish families with whom to celebrate the holidays).
The reason for this mitzvah is that, just like we need food, rest and exercise in the proper amounts, it’s important for us to get our recommended amount of joy. Rather than leaving it up to us to rejoice - perhaps frivolously and inappropriately - at any old time, God made it a mitzvah for us to rejoice in certain contexts for His sake. This type of rejoicing therefore creates a positive, healing balm for the soul. (And what better times than the Festivals which, as the name implies, ought to be festive?)
This mitzvah applies in all times and places. It is discussed in the Talmud in tractates Pesachim (109a), Chagigah (6a) and Kiddushin (34a-b). It is codified in the Shulchan Aruch in Orach Chaim 529. This mitzvah is #54 of the 248 positive mitzvos in the Rambam’s Sefer HaMitzvos and #21 of the 77 positive mitzvos that can be performed today as listed in the Sefer HaMitzvos HaKatzar of the Chofetz Chaim.