Actually the reason flies rub their hands together is because they’re grooming themselves. They rub their front, middle, and back legs to keep them clean so their senses don’t get messed up.
Flies also rub their eyes, antennae, and their wings for the same reason.
Many other insects and Arthropods do this as well including grasshoppers, centipedes, and beetles.
Some insects actually groom each other like honey bees, termites, and ants.