I gave my villager from the spawn egg a name tag and put it in a 1x2 block cage and he despawnte after 2 H, My question is if I did something wrong and you can replace it?
I'd suggest making a support ticket with this information so a higher member of staff can look into this for you and hopefully resolve it. I know there has been issues with villagers despawning, and to my knowledge this has been reported.