What is the wisdom behind the sunnah of shaving the newborn's hair?
It is a sunnah in Islam to shave the hair of a newborn. It is recommended to be done on the seventh day. The hair is then weighed, or by estimation. The weight of the hair is then calculated equivalent to the value of gold after which the money is given to the poor as a sadaqah.
From the religious point of view, it encourages us to show gratitude to Allah and to share the joy with the needy by giving them alms. This is in accordance with the word of God in the Quran:
"لئن شكرتم لأزيدنكم"
Which means: "If you are grateful, I will surely increase you [in favor]." (Surah Ibrahim: 7)
Physically, it removes the hair that has long been in the womb of the mother so as to clear the dirt that might be trapped in the hair and eventually grow new and healthy hair.