The halacha in Shulchan Aruch is that one may not dance or clap hands to a tune on Shabbos or Yom Tov. However, the common custom, particularly among Chasidim, is to be very lenient in this matter, since many poskim say that it is acceptable nowadays. They explain that the reason for the prohibition in the first place was that it might lead people to violate Shabbos or Yom Tov by repairing a malfunctioning musical instrument, but since nowadays most people are not capable of repairing musical instruments, the decree is no longer relevant. Even though not all poskim agree with this opinion, Chasidim rely on this leniency as well as other leniencies in this matter. Another reason discussed by poskim is that when the dancing and clapping is bsimcha shel mitzvah, rejoicing associated with a mitzvah, then it is similar to Simchas Torah when clapping and dancing is permitted in celebration of the Torah. Since Chassidim become very inspired when they daven, and in their fervor get carried away, it is considered simcha shel mitzvah when they clap and dance, just as on Simchas Torah. The Rebbe says that although dancing and clapping hands on Shabbos and Yom Tov requires unique halachic justification, as discussed above, it has become prevalent in our time when we are getting closer and closer to Moshiachs arrival. The esoteric rationale for this is that we are drawing closer to the era when My servant Dovid will rule over them, over the entire Jewish people, an eternal ruler. Accordingly, we emulate My servant David, who was joyously singing songs of praise and cavorting before G d. This additional joy will be a catalyst for hastening the geulah.