I couldn't find a command that gives the pig infinite health so just use:
/effect give @e[type=pig] minecraft:regeneration 999999 255 true
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
make sure to use that command after spawning the pig.
This is a tutorial that no-one asked for. It's how to turn into random animals in Minecraft with command blocks. It's like the morph mod.
If you enjoyed the video please subscribe so I don't feel sad :(
Ещё видео!