From a NYTimes Week in Review article titled “Crime (Sex) and Punishment (Stoning)“:
Stoning is not practiced only among Muslims, nor did it begin with Islam . . . The Old Testament includes an episode in which Moses arranges for a man who violated the Sabbath to be stoned, and stoning probably took place among Jewish communities in the ancient Near East. Rabbinic law, which was composed starting in the first century A.D., specifies stoning as the penalty for a variety of crimes, with elaborate instructions for how it should be carried out. But it is not clear to what extent it was used, if ever . . .
Stoning is not prescribed by the Koran. The punishment is rooted in Islamic legal traditions, known as hadiths, that designate it as the penalty for adultery. While the penalty may seem savage to Western eyes, scholars say it is consistent with the values of Arabian society at the time of Muhammad, Islam’s founding prophet. Adultery “was considered to offend some of the fundamental purposes of Islamic law: to protect lineage, family, honor and property,” said Kristen Stilt, an associate professor at Northwestern University who has written about Islamic law. “It was a tribal society, and knowing who children belonged to was very important.”
That may help explain the link between sexual crimes and stoning, as opposed to another form of execution. A crime that seemed to violate the community’s identity called for a communal response.
Some scholars . . . argue that the stoning penalty is meant more as a symbolic warning against misbehavior than as a punishment to be taken literally.