Shari`ah aims to preserve offspring, lineage, and honor. These are all related to chastity and purity. Islam has maintained many ways to establish virtue and spread it in the Muslim community: it has prohibited immorality, stirred up faith in the hearts, blocked the ways of temptations, and enjoined the companionship of righteous people.
On this subject Dr. Ahmad Ar-Raysuni, Professor of Shari`ah in Morocco, states:
Scholars stress that among the necessities and the main objectives of Shari`ah is preserving offspring, lineage, and honour, which are all dependent on maintaining chastity and legal, virtuous relations between the two sexes. On the other hand, the spread of immoralities such as adultery, sodomy, and all other forms of perversion and sexual deviation, represents a real danger to the preservation of such necessities, through which the human race is safeguarded and continues, and its proper growth and upbringing are guaranteed.
As it does when it handles any other issue, Islam in this concern depends first on increasing faith, the desire to seek divine reward, and the fear of divine punishment. In this way, Islam guarantees that chastity arises from one’s soul and inner faith. Moreover, Islam arouses the desire for Paradise and the fear of the Fire and uses conviction and persuasion to urge people to maintain chastity and avoid immorality. Almighty Allah says: (And come not near unto adultery. Lo! it is an abomination and an evil way) (Al-Isra’ 17: 32).
To illustrate, a young man came to the Prophet (peace and blessings be upon him) asking his permission to commit adultery. Upon that, the Prophet said to him, “Would you like it to be done with your mother?” The young man replied, “No! May Allah make my life be your ransom!” The Prophet then asked him if he would like it to be done with his sister or his maternal or paternal aunt. When the man answered in the negative and showed he did not like that his mother, sister, or aunt would commit adultery, the Prophet (peace and blessings be upon him) said to him, “And so are all men; no one would like you to commit adultery with his sister or daughter or any of his near female relatives.”
On the other hand, Islam has set many protective rulings to avoid immorality. For example, Islam prohibits women from adorning themselves when going out, wearing showy clothes or trying to sexually attract men. Likewise, Islam enjoins both men and women to lower their gaze from immoral things and prohibits a man and a woman to be alone in privacy [unless, of course, they are close relatives] to ward off satanic temptations and insinuations. In addition to all this, Islam sets severe, deterring punishments for adultery, perversion, and homosexuality, varying from scourging to stoning to death.
There is no doubt that temptations have become overwhelming nowadays, and it has become so hard for man to spare their effects. Yet, I say as the Prophet (peace and blessings be upon him) said to one of his Companions regarding another issue: “You have asked me about a great issue, yet it is certainly so easy for those whom Allah makes it easy for them.” That is to say, those who seek refuge in Allah, fear His might, seek His support, and seek the companionship of the righteous, will surely be able to safeguard themselves and preserve their honour.