Originally, apparently, one of the retinue attached to an estate, for the word “villain” stems from the Latin villanus, from villa, “a country house,” and this meaning was largely retained in an alternate spelling of the English word, villein.
But, progressing from the general sense of “a peasant,” in which sense the word dates back to the early fourteenth century, the use of the term was broadened to include anyone of low birth, then to one of ignoble instincts, and finally to its present sense where it applies to a scoundrel or criminal.
Related terms are known in most of the Romance languages, and the immediate source of the English form was the Anglo-French of the same or slightly different spelling.