Goats keep despawning no matter what. I have them closed in a cage, with the roof closed. There are no point for them to take fall damage, and I also play on peaceful, so there are no mobs or any ways for them to hurt themself. The enclosure is small, 10x10 (8blocks high) and it is full of light. Also one thing i noticed is that no matter how many goats i have, they will always despawn all at once. I had 10 goats, and I went to check on them everyday (since this already happened). Everyday i had 10 goats, but one day, 0 remained: each one of them despawned in the same exact time.
Did you name tag the goats?