If Surge of Righteousness resolves but the creature isn’t destroyed (perhaps because it regenerated or it has indestructible), you’ll still gain 2 life.
2015-02-25 • wotc
However, if the creature becomes an illegal target before Surge of Righteousness resolves, it won’t resolve and none of its effects will happen. You won’t gain life.