Minecraft wiki entry for Bartering_farm, associated text: Unlike most hostile mobs, they do not despawn in peaceful mode, but still follow normal hostile mob despawning rules. If you are caging up piglins for easier bartering, you will need to use name tags on them or give them a piece of gold armor, which will prevent them from despawning.