There's an old bar bet where a con bets the sucker that he can tie a cigarette in a knot without breaking the paper tube. The con wraps the cigarette tightly in the cellophane from the pack and then ties it in a knot. Ta da.
Same principle: wrapping the ends of the strings in thread makes them less likely to break, and as Greg pointed out, helps keep the windings together. The color and gauge of the thread also denotes manufacturer, string gauge, batch, intended pitch, whatever.
We only see them four at a time, but I suppose the color coding is handy for factory workers and bean-counters.
Two reasons why we see it in bass strings is primarily because one: orchestral double bass strings were the first composite strings - originally, metal tape wrapped around a core of sheep's intestine, yum - so the thread wrapping kept the whole string from unwinding, and two: metal tuning machines (as opposed to a peg in a hole) were first handcrafted for string basses around 500 years ago. The silk windings on the string prevented metal-to-metal contact, and made it less likely the string would slip on the post.