This is a good question, because king David did not have the whole truth at the time that he did this. In every other instance, dancing was a fruit of wickedness.
If you read on, David's actions had done this upon Michal:
2nd Samuel 6:16,20 And as the ark of the LORD came into the city of David, Michal Saul's daughter looked through a window, and saw king David leaping and dancing before the LORD; and she despised him in her heart. Then David returned to bless his household. And Michal the daughter of Saul came out to meet David, and said, How glorious was the king of Israel to day, who uncovered himself to day in the eyes of the handmaids of his servants, as one of the vain fellows shamelessly uncovereth himself!
This caused Michal to hate David in her heart so much that it formed a grudge that the LORD took note of - because the LORD protected David from his enemies.
2nd Samuel 6:23 Therefore Michal the daughter of Saul had no child unto the day of her death.
So, if dancing caused David to gain enemies... what else does it do? Let us read into other witnesses.
Matthew 14:6-8 But when Herod's birthday was kept, the daughter of Herodias danced before them, and pleased Herod. Whereupon he promised with an oath to give her whatsoever she would ask. And she, being before instructed of her mother, said, Give me here John Baptist's head in a charger.
Exodus 32:19 And it came to pass, as soon as he came nigh unto the camp, that he saw the calf, and the dancing: and Moses' anger waxed hot, and he cast the tables out of his hands, and brake them beneath the mount.
So, please... study into everything - do not rely on singular witnesses to build your worldview and doctrines. It is extremely dangerous if you do so.
The conclusion of the dancing matter is this: dancing does not please the LORD, but instead creates enemies and hardens hearts even further - just because David did it before the LORD does not mean that the LORD is pleased.