mid-15c., "free, exempt" (from taxes, tithes, sin, etc.), from Latin immunis "exempt from public service, untaxed; unburdened, not tributary," literally "not paying a share," from assimilated form of in- "not, opposite of" (see in- (1)) + munis "performing services" (compare municipal), from PIE *moi-n-es-, suffixed form of root *mei- (1) "to change, go, move." Specific modern medical sense of "exempt (from a disease)," typically because of inoculation, is from 1881, a back-formation from immunity. Immune system attested by 1917.
deficiency n.
1630s, "state of falling short, a lack or failing;" 1660s, "that in which a person or thing is deficient, inadequacy," from Late Latin deficientia, from deficient-, present-participle stem of deficere "to desert, revolt, fail," from de "down, away" (see de-) + combining form of facere "to do, make" (from PIE root *dhe- "to set, put"). The older English word, now rare or obsolete, was deficience (mid-15c.).