Flies rub their legs together as a way to clean them and remove debris. They also use this behavior to generate signals and communicate with other flies.