First of all, it should be noted that Islam cares much for the perseverance of morals and the maintenance of modesty and chastity in the Muslim society. To achieve this goal, Islam requires the highest degree of cautiousness when dealing with the members of the opposite sex. A Muslim is always asked to keep very remote from anything that stimulates him or stirs his sexual urge. This includes looks, gestures, or free mixing.
The laws of Islam are from Allah, our Creator, who knows our weaknesses as well as our strengths better than we do. Women, by nature, desire to be looked at, adored and cherished, while man is inclined to look at women. Allah therefore warns us against our own nature, which may lead us astray
if we do not exercise caution and take the necessary safeguards.
In the meantime, Islam has guaranteed the right of education for both men and women regarding it as an obligation upon every Muslim, male or female. The woman’s right to education is well established from the early days of Islam.
Undoubtedly, the free mixing of young boys and girls, close to the period of adolescence, in the relaxed environment of a school is very serious. It is a duty of Muslims to unite their efforts to eliminate this system in their countries and to set up schools, colleges and universities for both genders. Parents should search for separate schools to enroll their children. However, if a Muslim, male or female, is pressed to study at a mixed school, then he should exert his utmost to observe the Islamic standards of morality and keep away from all unlawful things.
Addressing the issue of co-education, we’d like to cite the following fatwa:

“There is a well-known principle in Islamic law, which may be rendered in translation as “blocking the means (of evils).” This applies to any situation or condition which may be permissible in the first instance, but is calculated to lead to something forbidden. If it is generally deemed that there is a direct relationship between the original, permissible situation and the resulting forbidden one, then the original situation is pronounced as forbidden.
This is the prohibition of something which is acknowledged to be permissible in the first instance, because of the results it produces. In other words, should the circumstances change and the situation in question is deemed not to lead to the forbidden act, then it can no longer be pronounced as forbidden.
Co-education is one of such things. In the first instance, there is no harm in a group of people, men and women, boys and girls, to be present in a classroom, listening to a lecture, provided that everyone behaves properly, abiding by Islamic teachings and codes of conduct. But when we put together a group of young boys and girls, close to the period of adolescence, in the relaxed environment of a school where they meet and play, then it is asking too much of such young people to observe Islamic standards of morality. The results may be very serious indeed.
Therefore, we say that co-education is Islamically unacceptable, because of what it leads to, not because of the process of teaching or of the meeting of the two sexes in a classroom.”
Excerpted, with slight modifications, from: www.islamicity.com

Shedding more light on the issue, we’d like to state that “co-education is not an issue that has specifically been addressed by the Shari`ah. In other words, what we should keep in mind is the fact that co-education has not categorically been proscribed by the Almighty. However, there is no question about the view that it should be avoided, keeping in view the essence of the Islamic teachings regarding gender interaction and also the dictates of our intuition.
As far as the arguments in favor of co-education are concerned, the strongest argument put forth by its proponents, is the exhortation that Islam has extended to Muslims to allow their women into mosques and let them offer prayer in congregation if they want to. Why on earth should it not be allowed in schools and colleges then? This seems to be the strongest of all arguments offered by them since, through this, they manipulate a religious directive in their own favor.
A little deliberation here will reveal that there is a world of difference between the environment of a mosque and that of a school. In mosques, we indeed have an overwhelming feeling of the presence of the Almighty. Moreover, our intentions to visit and our concept regarding the sanctity of the mosque make a real difference in this respect. In spite of all this, Islam further enjoins certain etiquette to be observed by both Muslim men and women while they are in their Lord’s House. They are never allowed to intermingle freely or sit side by side. Ladies are directed to cover themselves properly and men have been directed to lower their gaze of which they become profoundly aware when they enter the sacred house. Is the situation with schools the same? Of course not. It is for this reason that co-education in schools and colleges must not be extrapolated on the basis of the permission given to women to attend mosques.
In fact, the tremendous loss caused by co-education is moral degeneration. The students are completely exposed to the opposite sex. Curiosity plays its role well in this regard. The wrong ideals set by the media and the awful bombardment of immoral images and characters fill the space left out by the germs of curiosity implanted by Satan. This reality coupled with the fact that they are mostly devoid of the supervision of any true and sincere mentor at school in that their teachers themselves do not present their students with a role model of morality, cause the innocent students to fall prey to the deadly predator of sexual impurity.
Thus, the ideal situation that springs to mind when one takes into consideration the spirit of Islamic teachings and dictates of common sense is that provision of separate class rooms for male and female students is imperative. Therefore, it is incumbent upon the (Muslim) governments to make necessary arrangements in order to realize this end.”