Judaism prohibits shaving with a razor on the basis of a rabbinic interpretation of Leviticus 19:27, which states, "Ye shall not round the corners of your heads, neither shalt thou mar the corners of thy beard." The Mishnah interprets this as a prohibition on using a razor on the beard.
This prohibition is further expanded upon in kabbalistic literature.
In the Torah
The book of Leviticus in the Torah makes mention of corners of the head, and prohibits the marring of the corners of the beard, with particular emphasis on priests (kohanim) not marring the corners of the beard; as with many other parts of Leviticus, the Book of Ezekiel describes different regulations, stating that the priests should not shave their heads, or let their locks grow long.
However, there were exceptions, with the Book of Ezekiel itself adding that priests should keep their hair trimmed, and Leviticus arguing that, in certain cases of tzaraath, the beard and hair should be completely shaved away. Numbers (Ch. 6) additionally requires that Nazarites shave their heads, 7 days after any contact with corpses.
Origin
According to biblical scholars, the shaving of hair, particularly of the corners of the beard, was originally a mourning custom; the behaviour appears, from the Book of Jeremiah, to also have been practiced by other Semitic tribes, although some ancient manuscripts of the text read live in remote places rather than clip the corners of their hair. Biblical scholars think that the regulations against shaving hair may be an attack on the practice of offering hair to the dead, which was performed in the belief that it would obtain protection in sheol; Nazirites shaved after contact with a corpse, captive women shaved after mourning the death of their parents, and the general prohibition in the Holiness Code is immediately followed by a rule against people cutting their own bodies for the benefit of the dead.
Textual scholars date the Priestly Source, and the Holiness and Priestly Codes within it, to the late 7th century or later; it appears that before this time, the shaving of the head during mourning was permitted, and even encouraged. The Book of Amos, which is dated by textual scholars to the mid 7th century, as well as the Books of Isaiah and of Micah, which textual scholars date to a slightly later period, portray God as instructing the Israelites to shave their head as an act of mourning: ... God ... called you to weep and mourn. He told you to shave your heads in sorrow for your sins-
The prohibition against cutting the corners of the beard may also have been an attempt to distinguish the appearance of Israelites from that of the surrounding nations, and reduce the influence of foreign religions; Maimonides criticises it as being the custom of idolatrous priests. The Hittites and Elamites were clean-shaven, and the Sumerians were also frequently without a beard; conversely, the Egyptians and Libyans shaved the beard into very stylised elongated goatees.
In classical rabbinical literature
The forbidding of shaving the corners of the head was interpreted by the Mishnah as prohibiting the hair at the temples being cut so that the hairline was a straight line from behind the ears to the forehead; thus it was deemed necessary to retain sidelocks, leading to the development of a distinctly Jewish form of sidelock, known as payot. As for the beard, more complicated views arose; the corners of the beard were explained to refer to five extremities in the Talmud. There are many opinions in medieval scholars as to what these five points are. For example, it may be a point on each cheek near the temples, a point at the end of the cheek bone towards the centre of the face, and the point of the chin. Or it may be two on the mustache, two somewhere on the cheek, and one on the point on the chin. As a result, Shulchan Aruch prohibits the shaving of the entire beard and mustache.
Because the biblical prohibition against shaving uses the Hebrew word gelech (גלח), which refers to shaving with a blade against the skin, Talmudic rabbis interpreted it to only refer to a blade, and only to the hair being cut close to the roots, in a smooth manner. This means that only a razor would be prohibited, trimming or non-razor shaving would be permitted. In the ancient land of Israel, it was common among more scholarly circles of Jews to clip beards.