This problem could be caused in multiple ways:
- Lack of lighting. (zombies could appear and killing all the villagers. Zombies do despawn.)
- Having villagers on transparant blocks such as: Stairs, slabs, glas, glowstone etc (mostly only bottom slabs or stairs cause this problem though). Might glitch a villager in it while moving between chunks at the wrong time.
- No roof above the villagers could also cause them being struck by lightning.
And there are more of these possible problems.
Here are some things you could try to keep the villagers safe:
- Light the area properly.
- Make it impossible for skeletons to shoot them.
- make sure that there is atleast a 2 block width wall between the villagers and other mobs. (sometimes zombies can hit a villager trough 1 block (happend to me before on a different server)
- Make sure there is a roof above the villagers. (Ussualy i would go for glass or other blocks on which Mobs can't spawn.
- I don't know if doors are necessary but i ussualy have doors within range of my villagers.