From ancient times, the color blue was considered a precaution against evil spirits, since blue was the color of the heavenly sky.
Dressing a baby boy in blue protected him from the evil spirits who wanted to cause him harm.
Since girls were considered inferior, it was assumed that evil spirits would not bother with them, and they were dressed in any old color.
Much later, people became conscious of the lack of a special color for girls, and pink became standard.