I have had this happen to me on a minecraft realm several times, and once on a single player save over the course of a few weeks, all in 1.14.4, all with zero (Even client side only) mods.
Singleplayer:
Setup base in village. Went mining under village one day and returned to zero villagers. There were several iron golems, but I assumed this time they got overwhelmed by a zombie raid or something.
Realms:
First time was on a regular desert village. Large village with 8 iron golems spawned, so I doubted it was mobs, still had enough to repopulate it. This one has had almost all the villagers about three times.
Next was in the village I created in a ravine. Villagers are completely boxed in with iron doors at all entrances/exits and fences and walls surrounding every walkway. This has happened about 3 times, however, two of the times, I found most of the villagers hidden in a small 1x2x1 space ON THE OTHER SIDE OF A WALL. I only found them after hearing a lot of Hrrms in a certain rooms and mined out a hole where the sounds were coming from when about 15 of them all exploded out like a clown car. There is also no way the missing guys died to mobs somehow, as there is about 40 iron golems in the village concentrated at the entrance and the dormitories.
Finally, a successful iron golem farm lost 4/6 villagers that were completely boxed in in a 1x2x1 space after spending much time wrangling them into place. It took a lot of effort to trap them there so I'm kind of just giving up on minecraft for the moment. In this instance, all villagers in the farm were name tagged, as I thought that may help with preventing their disappearance. This instance I was AFK a handful of chunks away, but under ground from the Iron golem farm, so it seems to happen whether my character sleeps or not.
I think some of this may be as users have said, been because they are near a chunk border, as a lot of the beds in the desert village and in the iron golem farm were touching (but not crossing over) a chunk border after using F3 + G to inspect. However, only a handful of the beds in the ravine village have beds touching or crossing chunk borders.
I have had this happen to me on a minecraft realm several times, and once on a single player save over the course of a few weeks, all in 1.14.4, all with zero (Even client side only) mods.
Singleplayer:
Setup base in village. Went mining under village one day and returned to zero villagers. There were several iron golems, but I assumed this time they got overwhelmed by a zombie raid or something.
Realms:
First time was on a regular desert village. Large village with 8 iron golems spawned, so I doubted it was mobs, still had enough to repopulate it. This one has had almost all the villagers about three times.
Next was in the village I created in a ravine. Villagers are completely boxed in with iron doors at all entrances/exits and fences and walls surrounding every walkway. This has happened about 3 times, however, two of the times, I found most of the villagers hidden in a small 1x2x1 space ON THE OTHER SIDE OF A WALL. I only found them after hearing a lot of Hrrms in a certain rooms and mined out a hole where the sounds were coming from when about 15 of them all exploded out like a clown car. There is also no way the missing guys died to mobs somehow, as there is about 40 iron golems in the village concentrated at the entrance and the dormitories.
Finally, a successful iron golem farm lost 4/6 villagers that were completely boxed in in a 1x2x1 space after spending much time wrangling them into place. It took a lot of effort to trap them there so I'm kind of just giving up on minecraft for the moment. In this instance, all villagers in the farm were name tagged, as I thought that may help with preventing their disappearance. This instance I was AFK a handful of chunks away, but under ground from the Iron golem farm, so it seems to happen whether my character sleeps or not.
EDIT: This was the farm setup https://www.youtube.com/watch?v=q08sHGmuNUA
I think some of this may be as users have said, been because they are near a chunk border, as a lot of the beds in the desert village and in the iron golem farm were touching (but not crossing over) a chunk border after using F3 + G to inspect. However, only a handful of the beds in the ravine village have beds touching or crossing chunk borders.