From the Super Mario Wiki
Ads keep the MarioWiki independent and free :)
The Invincibility Egg is an item found only in Yoshi's Woolly World. The item will appear once a Yoshi has been defeated 5 times, much like the Super Guides from New Super Mario Bros. Wii, Super Mario Galaxy 2, and New Super Mario Bros. U and can be considered the Yoshi counterpart to the Invincibility Leaf from Super Mario 3D Land, New Super Mario Bros. 2, and Super Mario 3D World. The major difference, however, is that there is no negative effect on game completion if Yoshi uses the Egg.
Like the name of the item implies, it grants a Yoshi invincibility to damage by enemies, signified by Yoshi glowing multiple colors. However, no knockback resistance is given, i.e. Yoshi can still be pushed around by enemies and their attacks without being harmed and unlike most cases of invincibility, Yoshi cannot defeat foes instantly by merely touching them. There is also no immunity to damage caused by spikes, lava, being crushed, touching Naval Piranha in World 4-S, and bottomless pits with the Egg's power, but with certain Power Badges, Yoshi can combine the Egg's power with either immunity to fire and lava or bottomless pits.