>>12501254It comes form the association of wealth to color.
In old days boys were considered more valuable than girls ( like a lot of 3rd world countries today ). Blue was a harder and more expensive color to come by while pinks and reds were much cheaper and more common.
Rich people would often dress their children in blue as a mark of their status. The peasants, being fucking peasants, would imitate this when they could, but especially so when the middle class began to emerge during the industrial revolution, but with limited funds would reserve blue for their male children, mollifying their female children with the "blue for boys and pink for girls" bullshit. It became entrenched as a social custom over time regardless of wealth and especially so when new industrial methods made blue clothing as cheap as anything else.
I just made all this up, but it sounds about right.