In the late 1800s, female African American slaves and sharecroppers wore cloths over their heads to tie their hair back with. In the 1930s, the practice evolved into a method to preserve a wavy hairstyle, and the rags were worn at night. By the 1960s, however, partially due to the Black Power movement, it became an actually popular style to wear hairdo-rags, or do-rags, as they were soon called (an interesting example of clipping). People started wearing them in public as a fashionable accessory, and the clothing piece was especially popularized by rappers at the time. Eventually, even the spelling started to shift: the pronunciation remained the same, but it became more in vogue to start spelling it durag, no apostrophe. Today, almost everyone spells it that way (durag has more usage in Google Trends than all the other terms combined), but Merriam-Webster and Wikipedia stick to do-rag because of etymological fallacy, I suppose.
Adam Aleksic, a rising sophomore studying linguistics and government at Harvard University, has been described as the internet's sixth most famous etymologist. He also has disturbing interests in politics, vexillology, geography, board games, conlanging, and law.