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."
Islam is a deen (way of life) of human nature and men and women have traditional roles in Islam and each fulfills their role in the society according to their natures created by Allah ﷻ. The hadith specifically expresses Prophet's concern when he heard about a woman taking leadership of an empire with its political, military, international and highly important affairs of that state. His concern was not to prevent women from assuming leadership roles in general societal affairs such as trading, education, medicine etc. which unfortunately has been misinterpreted by many. In Islam males are given preference over females when it comes to ruling affairs of the state. 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 khalifa (viceroy, representative).." In Islam a khalifa (representative) is someone who is handed over the responsibility and shoulder's it as a trust. Allah ﷻ preferred Adam (alaihi salaam) to be His first prophet and khalifa or caliph (representative) on earth instead of Hawwa (Eve) because Adam (alaihi salaam) has been handed the trust of rulership, the greatest responsibility in any given society. Hence the verse teaches us a crucial point that prophethood & rulership are synonymous with each other which is further emphasized by Prophet Muhammad ﷺ when he said: "The Banu Israil (children of Israel) were ruled by the Prophets. When one Prophet died, another succeeded him. There will be no Prophet after me. Caliphs will come after me, and they will be many.”  Hence we notice the fact that all prophets and messengers that have ever lived in human history were male and none were female. Therefore even though prophethood came to its completion with the arrival of Prophet Muhammad ﷺ the rulers will now succeed the prophets, and the successors of the prophets like the prophets can only be male.
Hence having designated Prophet Adam (a.s) as His first representative and prophet, Allah ﷻ has given his male descendants the primary responsibility for the use of land, its resources and those subordinate to them and rule them with the law and guidance that has continued to be revealed throughout human history. It is also due to this reason as a rule in Islam a leader leads the Friday prayers and important festivities such as Hajj and Eid prayers etc. which women cannot. Also, there is continuous process of decision making involved for leaders as political authorities or 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 these modern times, even among highly developed secular nations, none has a woman serving as their chief of armed forces and extremely fewer number of women serve in the armed forces, or serving as presidents & prime ministers, due to obvious natural reasons.
A question arises if the Prophet ﷺ mean’t that women cannot succeed at all if they becomes rulers?
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 Muslim women became state rulers 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, yet 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
 Riyad us-saliheen Book 1, Hadith 656 – Sunnah.com