Notice a more modern rendering of these verses in the New King James: "You shall not shave around the sides of your head, nor shall you disfigure the edges of your beard" (Leviticus 19:27); and, "They shall not make any bald place on their heads, nor shall they shave the edges of their beards nor make any cuttings in their flesh" (Leviticus 21:5). It is quite plain that this proscribes a particular kind of shaving or cutting of hair.
It was a ritual custom of the heathen to cut or trim their beards and hair into special shapes in honor of a particular pagan deity. To honor the sun god Ra, the ancient Egyptians had their dark locks cropped short or shaved with great care so the hair that remained on the crown appeared in the form of a circle surrounding the head (from which the halo derives), while the beard was dressed in a square form. Alternatively, a round bald spot might be shaved on the head.
It is this type of false worship the Bible forbids. Shaving one's beard and cutting one's hair for normal good grooming is something entirely different and not at all condemned in the Scriptures. In fact, the apostle Paul takes great pains to address proper grooming of one's hair in I Corinthians 11:2-15.