Narrated Ibn ‘Umar:
The Prophet said, “A woman should not travel for more than three days except with a Dhi-Mahram (i.e. a male with whom she cannot marry at all, e.g. her brother, father, grandfather, etc.) or her own husband.)”
The Prophet said, “A woman should not travel for more than three days except with a Mahram.”
Narrated Abu Huraira:
The Prophet (p.b.u.h) said, “It is not permissible for a woman who believes in Allah and the Last Day to travel for one day and night except with a Mahram.”
The saheeh (authentic) Sunnah indicates that it is not permissible for a woman to travel except with a mahram. This travelling is not defined by a specific distance, as is the case with shortening the prayers or breaking the fast, rather everything that is called travelling, whether it is long or short, is not permitted for a woman unless she has a mahram with her.
Al-Bukhaari (1729) and Muslim (2391) narrated that Ibn ‘Abbaas (may Allaah be pleased with him) said: The Prophet (peace and blessings of Allaah be upon him) said: “No woman should travel except with a mahram.”
The fuqaha’ are unanimously agreed that it is haraam for a woman to travel without a mahram, except in a few exceptional cases, such as travelling for the obligatory Hajj, for which some of them have permitted a women to travel with trustworthy companions. Al-Haafiz Ibn Hajar (may Allaah have mercy on him) said: al-Baghawi said: They did not differ concerning the fact that a woman may not travel for anything but the obligatory Hajj except with a husband or mahram, except a kaafir woman who becomes Muslim in daar al-harb or a female captive who escapes. Others added: or a woman who becomes separated from her group and is found by a trustworthy man, in which case it is permissible for him to accompany her until he brings her back to her group. End quote from Fath al-Baari (4/76).
For a very detailed and satisfactory answer, including the wisdom and reasons behind this ruling, read this.