There is a mitzva to celebrate the festivals together with friends and neighbors who are poor and lonely, as we read: “You shall rejoice in your festival with … the Levite, the stranger, the orphan, and the widow in your communities” (ibid.). Widows and orphans were generally poor, as they no longer have providers. The strangers who had left their own country and family generally suffered from loneliness. Maimonides writes powerfully: “Someone who is eating and drinking [on a festival] is obligated to feed the stranger, the orphan, and the widow, along with the rest of the wretched poor. In contrast, someone who locks the doors of his home and eats and drinks with his wife and children, but does not feed the poor and embittered, is not experiencing the joy of a mitzva, but only the joy of his gut. . . Such joy is an embarrassment to them” (Mishneh Torah, Laws of Yom Tov 6:18).
Nowadays, the mitzva to bring joy to the poor is primarily accomplished through giving them money to meet their needs. The mitzva to bring joy to the lonely and broken-hearted is primarily accomplished through inviting them to participate in the festival meals.