Hi,
When variants don't have images, they use the images of the main product.
Remove that code will remove the variants images from the HTML and only leave the default ones.
That way, HikaShop won't do any replacing of the images when you switch the variants.
If you don't have images in the variants, you indeed don't need that code, and it can potentially mess with the rest of the page if the customization made on the product page has some issue.
So yes, that was probably what I would have told you to do.