Narrated Abu Bakra: During the battle of Al-Jamal, Allah benefited me with a Word (I heard from the Prophet). When the Prophet heard the news that the people of the Persia had made the daughter of Khosraw their Queen (ruler), he said, "Never will succeed such a nation as makes a woman their ruler."
Men and women have traditional roles in Islam and each fulfills their role in the society according to their natures as Allah ﷻ created them because Islam is a deen (way of life) of human nature. The hadith specifically expresses Prophet's concern when he heard about a woman taking leadership of an empire with its political, military, international relations and highly important affairs of that state. His concern was not about women assuming leadership roles in general societal affairs such as trading, education, medical affairs etc. In Islam males are given preference over females when it comes to leadership roles in major and strategic affairs such as political and military. Allah ﷻ has said in the Quran when he created Adam (alaihi salaam): (Al Quran 2:30) "… I am going to place in the earth a khalif (viceroy, representative).." Allah ﷻ preferred Adam (alaihi salaam) to be His representative on earth instead of Hawwa (Eve) because Adam has been handed the trust of rulership, the greatest responsibility in any given society. Being a ruler he is responsible for the use of land, its resources and those subordinate to him and rule them with the law and guidance that has continued to be revealed for humankind through Prophets & Messengers. Due to this reason a leader in Islam leads the Friday prayers and important festivities such as Hajj and Eid prayers etc which women cannot. There is continuous process of decision making required as a political authority or a chief of armed forces, a role inconsistent with the physiological and psychological make up of women because during pregnancies and menstrual cycles their decision making might be impacted. Its extremely important to note that even in this modern age, among majority secular nations, none has a woman serving as their chief of armed forces and extremely few have women acting as presidents are also men, due to obvious natural reasons.
Now the question arises if the Prophet mean’t that women cannot succeed at all if they becomes leaders?
The hadith does not preclude the possibility of women not being able to become rulers at all. There are exceptions and Islamic history confirms how great women became took such roles and proved their skills, in fact even better in some ways than many men. Despite the fact that generally speaking women undergo physiological and psychological changes some women have displayed exceptional qualities such as Sayyida al Hurra (1515-1542 CE) - the title "sayyida al Hurra" means "noble lady who is free and independent; the woman sovereign who bows to no superior authority." She played a significant role in the brave defense of her people in the Maghreb (North Africa) region against the Spanish and other European pirates in the Mediterranean. Arwa al-Sulayhi of Yemen (1048–1138 CE) - Arwa is said by the chroniclers of her time to be brave, devout and have an independent character. She was also seen as highly intelligent and well learned, having a great memory for poems, stories and historical events. Hence women in Islam can take such leadership roles, however the matter of preference takes precedence in Islam due to natural make up of each gender and the role each plays within the Islamic environment and in order to maintain the continuacy of that preference the Prophet ﷺ discouraged their rulership by stating: “Never will succeed such a nation as makes a woman their ruler.”
 Sahih al-Bukhari 7099 - www.Sunnah.com