RAW, the spell always works when it is cast.
As mentioned by jkat718's answer and wax eagle's answer, the mechanics that determine whether spells actually take effect fall into three categories:
- Spell Attacks - the caster makes an Attack Roll, comparing the result to the targets Armour Class.
- Saving Throws - the target makes a Saving Throw, comparing the result to the caster's Spell Save Difficulty Class.
- Situational - no rolls are made, as whether or not the spell takes effect is not determined by chance, but rather by whether the requirements of the spell are fulfilled.
The first two categories are determined dynamically and apply exclusively to spells that would normally be considered offensive, but last category (under which healing spells fall) can apply to both friendly and offensive spells: consider Power Word Kill (Basic Rules, p. 98) which requires a target with less than 100 HP, but not an Attack Roll or Saving Throw. For all spells in this category (including healing/friendly spells), the spell manifests if its requirements are met, with no RAW chance to resist.
RAI, there may still be a way to avoid it.
However, a character could reasonably try to avoid such a spell's outcome by avoiding the spell entirely. An obvious way would be by blocking the spell with Counterspell (Basic Rules, p. 86) but this method gives us a clue as to other ways the spell might be prevented; Counterspell's casting time is:
1 reaction, which you take when you see a creature within 60 feet of you casting a spell
You have to be aware that your target is casting a spell in order to counter it. It therefore stands to reason that if you were aware someone was casting a spell you might do something else to interrupt them, such as move out of range, providing you have a reaction (which I'd usually rule you have out of combat) and taking such an action would not take longer than the casting time of the spell in question.
For example, Cure Wounds (Basic Rules, p. 86) has a range of touch, a casting time of one action, and uses verbal and somatic components. It would therefore be obvious enough that some sort of spell is being cast. If you had reason to try to avoid it, you might try to avoid being touched - probably prompting a dexterity skill contest.
Perhaps a more likely example would be Geas (PHB, p. 244) where a DM could reasonably rule that if the target notices the verbal components of the spell, they could attempt to get further than it's 60 foot range away before the casting time of 1 minute has passed (or perhaps cast Silence on the caster before they can complete those components). This is, however, more contentious, as there's no stipulation that the target must remain within 60 feet for the duration, but if the target of Cure Wounds notices in time to avoid being touched at all, then even RAW the spell cannot be cast.