Why would a man in his fifties want to marry a child of 6 in the first place? Please answer that! As for its legality, that was Muhammad’s doing, not God’s!
The prophet (s) married Aisha because God commanded it, there are many reasons, it could have been to protect the new religion from her fathers plans, as abu bakr would plan and plot to destroy the new religion, having his daughter marry the prophet would mean that his plans would at the very least be postponed until the new religion takes root, this would also apply to the prophets’ marriage to Umar’s daughter.
Another reason could be to test the wives specifically and the muslims in General. Aisha played a big role in the first civil war in Islam and was responsible for the deaths of thousands of people.
The great companion of Imam Ali (as), Ammar bin yasir recognized this when Aisha went out to Basra to fight imam Ali (as), he said “
But Allah has put you to test whether you obey Him or her (Aisha)”
Ammar recognized that Aisha would not have had the ability to influence people and mobilize an entire army had she not been the wife of the prophet. Therefore, Aisha was a source of trial and test for the Muslim nation. The prophet (s) married her fully aware she would go against his religion, command, and lead an army against his successor. Through the resulting strife between the two parties Allah (swt) would try and test this nation to see who will follow the prophet (s) and be among the believers and who will follow Aisha and be among the unbelievers.
This is what Ammar yasir (RA) was alluding to when he said “Allah has put you to test whether you obey Him or her (Aisha)” That is to say obeying Aisha is not obeying God.
We know that Aisha would not be able to mobilize people against the rightful khalif of the Muslims had she not been the wife of the prophet pbuh. She exploited her status to affect and mislead the Muslims, Allah (swt) granted her the ability to reach this place as wife of the prophet just as He granted it to the wives of Noah and Lot (as). It is for the same reason He granted Satan the ability to live until the day of judgment and gave him the many abilities that Satan uses to effect mankind and mislead them.
This is part of the divine trials and tests, and without it there would be no way to differentiate the truthful from the liar and the believer from the unbeliever.
I also believe that you have to judge according to the social norms of the time, we may not agree with it now but marriage at a young age was a common practice back then.
Even the prophet’s own daughter, Lady Fatima (as) was married to Imam Ali (as) at a young age, by the time she passed away she was 18 years old and had 2 toddler boys and 1 girl and was pregnant with her 3rd son. Marriage at a young age was a fact of life back then. However I don’t believe that Aisha was 6 years old when she was married to the prophet, I believe this was a fabrication by her. Maybe because there were rumors that she wasn’t a virgin when she was married to the prophet so in order to dispel this idea, she lied about her age at marriage.