Where did the turban come from...wow a good question and one that you are not going to easily find an answer too. Unlike sikhism where the turban/pagri carries a positive conotation(equality,sikhism,religion,kakkar), turbans outisde sikhism and in the ancient days have usually carried a negative/occult/esoteric connotation and have always been related to secret societies, members of ancient mystical schools, philosophers and illumined brotherhoods.
As far as the origins of the turban it is not very clear but the acient hebrew/quabalists/brotherhoods before judaism and after used to not only wear a turban BUT had to keep unshorn hair, they very much looked like sikhs. I am also under the impression that certain members/ranks in other civilizations around the world in ancient times also used to wear turbans such as egyptian/babylonian but again there is a sort of an occult/esoteric mystery as to why ancients used to wear turbans. I have seen a picture of British Aliester Crowly a satanist, illuminist, 33rd degree freemason and one of the most influencial men in the 20th century wearing a turban, so again there is that occult aspect to the turban. Hope this helps!