How to detect when a player looks at a pig with name "173"

Solution 1:

facing is completely separate from if entity <selector>, it just changes how the command is run (with a different rotation). Detecting if a player looks at something is very hard and requires something called "raytracing" (one example is here).
It might be possible to somehow check if the player looks at an enderman, but even if they're "invisible", you can still see the eyes, so that's probably not what you want.

I recommend changing something else about your setup so that you don't require to check for looking at a pig.