Kano Jigoro, the founder of judo, introduced the colored belt ranking system in order to denote his students' rank and progress. Initially, there was no specific visible way to differentiate between yudansha (dan ranks) and mudansha (initiates who hadn't yet attained dan ranks).
Kano invented this ranking system in 1883, when he awarded his students 'shodan or dan ranks'. In those times, black and while obis (sash for traditional Japanese dress) were worn with uniform kimono (a loose robe) in order to differentiate between the yudansha and mudansha.
In 1907, Kano introduced the modern gi and its modern obi, using the traditional white and black colors, though other martial art forms later adopted the custom or variation of it, and started using different colored sashes to indicate ranks.
Each martial art form has its own belt color order in accordance to its rank structure. Corresponding to the rank, colors tend to progress from lightest to darkest.
To sum up, we can say that the colors of the karate belts are the result or way of showing commitment and discipline to this form of martial arts. Hence, each belt has to be earned to be worn, and it takes a number of years to accomplish and attain the highest level of karate―the black belt.