Essence Drain deals 3 damage to any target and you gain 3 life.
If the target permanent or player is an illegal target when Essence Drain tries to resolve, it won’t resolve and none of its effects will happen. You won’t gain 3 life.