Look at these Muslim men doing dramas of decency by not shaking hands with women.

On one side Islam made life difficult for a woman in name of “Hijab and Decency حياء”, and practically imprisoned her in her home, and cut her off from the outside world, she could not even talk with other men, and even if she has to talk, then she must talk in a hard voice.

But on the other hand, Prophet Muhammad used to walk in public while holding the hands of the slave girls of another man in his hand.

Sunan Ibn Majah, Hadith 4177:
“If a female slave among the people of Al-Medinah were to take the hand of the Messenger of Allah, he would not take his hand away from hers until she had taken him wherever she wanted in Al-Medinah so that her needs may be met.”
Grade: Sahih (Darussalam)

Please remember that this slave girl was there with naked breasts too, which makes things more complicated.

Why did prophet Muhammad need to take her hand in his hand? Why were they not able to move in the city without taking each other’s hands?

This same tradition is also present in Sahih Bukhari too.

Sahih Bukhari, Hadith 6072:
Anas bin Malik said, "Any of the female slaves of Medina could take hold of the hand of Allah's Apostle and take him wherever she wished."

Why these two opposite extremes?

On one side, not only hairs but the whole body of a free woman is imprisoned in Jilbab. Or even worse, she is practically imprisoned in the 4 walls of the house. She is compelled to lead an unnatural life, where she is not even allowed to talk with men. 

But on the other side, even the breasts of the slave women were kept naked. And even customers could touch their private parts like sheep and cattle. And Muhammad was moving while holding the hands of the slave women of another people. 

Yes, these are the two opposite extremes.

This happens when no Allah is present above in the heavens, and a human with intellect level of Muhammad had to make the revelations on his own.