1520s, "period of 40 days in which a widow has the right to remain in her dead husband's house." Earlier (15c.), "desert in which Christ fasted for 40 days," from Latin quadraginta "forty," related to quattuor "four" (see four).
Sense of "period a ship suspected of carrying disease is kept in isolation" is 1660s, from Italian quarantina giorni, literally "space of forty days," from quaranta "forty," from Latin quadraginta. So called from the Venetian custom of keeping ships from plague-stricken countries waiting off its port for 40 days (first enforced at Ragusa late 14c.). The extended sense of "any period of isolation" is from 1670s.