1 They are for decoration
Villagers in Clash of clans don't do anything. They just move randomly in the village, get inside the town hall in a random manner and clap at certain buildings randomly.
2 They can reveal hidden Tesla
Villagers sometimes clap randomly as they stop by a certain building. During this process, a villager can reveal the location of a hidden Tesla to a scouting enemy. See how to reduce the attacks on your village.
3 They clap next to buildings
Villagers move randomly in a village and might stop next to a building and clap. There seems to be no use for this kind of move except entertaining the players.
4 They hide during attacks
When your village is attacked, the villagers will hide inside the town hall. If the town hall gets destroyed before they reach it, they will still go to its previous location then disappear. See also how to protect your resources.
5 Villagers will not reveal trap locations
While villagers can clap beside hidden Tesla, they still won't do that beside any trap. Villagers will never reveal the location of your traps to a scouting attacker.
6 They tell you when you get attacked
When you get attached, a villager will show up telling you that you are under attack. This will happen if you checked the game during an attack on your village.
7 They applause your work
Villagers can applause your work by clapping and nodding at random structures you built.
8 They move randomly
Villagers move randomly without any specific plan or path.
9 They can help you find obstacles
If obstacles are not clear, you might use the help of a villager to find them. Just find where a villager is heading, and they will find one of the obstacles around your village sooner or later.