It's primarily an effect of the camera fooling around with the white balance and contrast/light to try to get a correct image and failed.
This is not the whole story - the first time I saw it I saw a strongly blue/black dress, which no apparent white balance issues..
The white balance being off is part of the effect to be sure. But so is the surroundings (as XKCD refers to). But that's not the main story either, because no matter what I do both sides of the XKCD image look at least light blue. In some conditions the dress in the original photo appears pure white.
I think it's combination of all those factors but then at the end, a large push from the brain one direction or the other.
The individual theories are like the blind man around the elephant, each convinced it knows what is there from a part...
Add to it that the picture looks different depending on which display you have
That's the thing - looking at the EXACT SAME DISPLAY from minute to minute can show you different colors. I've seen it flip multiple times, on the same monitor in the same lighting conditions. That's the aspect that is amazing to most people, is they can see it change under almost any condition.