Wa alykum as-salaam,
This Hadith, from Bukhari, is misunderstood constantly, because (unsurpringly) it is dependent upon its context for someone to understand it, especially when you factor in what The Qur’an says about such an issue.
First, I’d like to establish that women are independent human beings, and this concept is enshrined within The Qur’an, when we read how women are given duties, as their own independent person:
"O Prophet! Whenever believing women come unto thee to pledge their allegiance to thee, [pledging] that [henceforth] they would not ascribe divinity, in any way, to aught but God, and would not steal, and would not commit adultery, and would not kill their children, and would not indulge in slander, falsely devising it out of nothingness: and would not disobey thee in anything [that thou declarest to be] right - then accept their pledge of allegiance, and pray to God to forgive them their [past] sins: for, behold, God is much-forgiving, a dispenser of grace." [60:12] Muhammad Asad
Therefore, being a woman does not limit the responsibilities and duties within Islam, so let’s us build up from this base point.
Now, what is the context of this Hadith, if we consider this aspect of The Qur’an? It would seem contradictory, wouldn’t it? Without context, of course it would, so let’s dive in:
When The Prophet said this, he was discussing the Sassanid Empire, otherwise referred to as the Persian Empire (indeed there have been many) and it was within this context that The Prophet made his remark. He was referring to Azarmidokht and Borandukht, who were sisters, and some of the last rulers of the Sassanid Empire.
They weren’t exactly great rulers, and their Empire was falling apart. Another factor was that, the Sassanids had never accounted for a woman becoming their ruler, that the populations were actually revolting. Indeed, civil war and various assassinations were used by both women in order to attempt to establish some semblance of order, but, they were unable to do so.
Thus, the comment could also be seen as a reference to the unclear method of succession, which was predicated on blood-related, male descendants, in which a female offspring would destroy such an arrangement. Regardless, the point is, The Prophet was referring specifically to this context, and not as a general rule, contrary to what others may wish or argue for.
How can I argue for such a position? Easy, with The Qur’an.
In The Qur’an, we get the story of Solomon (Suleiman) and his interaction with the Queen of Sheba, referred to as Bilqis (and other spellings), was the leader of her country and was urged to accept the monotheism of Abraham by Solomon. She duly accepts the Faith.
The importance of this story is that it illustrates how a woman’s leadership is characterized, that the quality of the leadership is based upon one’s faithfulness to God: which is to be just. Nothing about her rule is characterized as anything out of line, save her previous worship of other than God.
In fact, Solomon describes her as:
"Behold, I found there a woman ruling over them; and she has been given [abundance] of all [good] things, and hers is a mighty throne." [27:23] Muhammad Asad
So, it becomes clear that the context described above must be true, and that even if someone argues that it isn’t, they have to deal with the story of the Queen of Sheba within The Qur’an, which does not hint or even suggest that women are unable to rule over a state. Therefore, it becomes rather clear that The Prophet’s statement is not out of line with The Qur’an, because, he was speaking about the specifics of the Sassanid Empire, which did indeed fall, by the way.
Insha Allah, I hope this answers your question, and that if you, or anyone else, has a question on this, or any other subject, please do not hesitate to ask me.