If the target creature or planeswalker is an illegal target by the time Noxious Grasp tries to resolve, the spell doesn’t resolve. You won’t gain life. If the target is legal but not destroyed (most likely because it has indestructible), you will gain life.