If the creature is an illegal target as Pharika's Cure tries to resolve, it won't resolve and none of its effects will happen. You won't gain life. If, on the other hand, Pharika's Cure does resolve but the damage is prevented, you'll still gain life.