"I [once] had forbid you from visiting graves, [and I now enjoin] you to do so, so that the visit may serve as a beneficial reminder." (related by Muslim and others)
and in the version of al-Haakim:
"… for [such visits] soften the heart, bring tears to the eyes, and serve as a reminder of the Hereafter, [but be careful] not to speak forbidden expressions [i.e. while visiting]." (Sahih al-Jaami' 4584)
Concerning visits to cemeteries by women, scholars have varied opinions on this issue:
it is allowed or preferred and their case is similar to that of men
it is makrooh (reprehensible), which is the opinion of jumhoor ul-'ulemaa' (the majority of the scholars)
it is forbidden, this one probably being the strongest opinion, as indicated by al-hadith al-sahih in which the Prophet (peace be upon him) said:
"Allah has cursed women who frequent graves," related by Ahmed and Tirmidhi and Ibn Maajah and in one version,
"Allah has cursed women who visit graves and those who build mosques and place lights upon them." (related by Abu Dawood, al-Tirmidhi, al-Nisaa'i and al-Haakim)
This condemnation would warrant the validity of the argument against women visiting cemeteries as the lawmaker (i.e. Allah) would not condemn something that is permissible or reprehensible—only that which is forbidden completely.
Regarding what would be the reason for this condemnation, the scholars have cited two main arguments:
Firstly, that women for the most part are emotionally weaker in accepting calamities and perhaps being in sight of her dear one's graves may break into wailing and loud weeping, which would be detrimental to her religious character and harmful for her body as well.
Secondly, cemeteries are oftentimes isolated places which may not be safe for someone being alone, possibly exposing a woman to people of corrupt or loose moral character.
In summary, the rationale behind this prohibition is that women are often not as strong emotionally in the face of calamities, and not visiting graves prevents them from the trial and from being exposed to unnecessary fitnah.
Allah the Most Knowledgeable knows what is most correct and best.