Many martial arts (karate, judo, jiujutsu, taekwondo, kung-fu, etc.) use some form of coloured belts to denote rank and level. How did this come about? Did the concept have common origin or did some styles create the idea independently?
The first ranking system in Japanese arts was a merit system based on menkyo or licenses. Essentially, you trained until you learned enough to earn a license recognizing your ability in that set of techniques or lessons. You may have a menkyo for each section of the syllabus (mokuroku), or you might have menkyo shoden, menkyo chuden, etc. Ultimately, though, this culminated in a final license, menkyo kaiden (license of full transmission).
Kanō Jigorō (嘉納治五郎) was the first to incorporate a system of Kyu and Dan into martial arts, but this system actually originated in a chess-like game called Go (Igo in Japanese, Weiqi in Chinese). He split his students first into two ranks (Unranked, or mudansha; and ranked, or yudansha), and instituted a belt system to recognize the difference between them. These were later divided into levels of Kyu (white belt) and Dan (black belt) based on the rankings in Go.
The colored belts came after Judo began to be taught outside of Japan. Sensei Kawaishi Mikonosuke (川石酒造之助) introduced various colored belts in Europe in 1935 when he started to teach judo in Paris. The story goes that he felt that the Europeans he was teaching needed some sort of encouragement to continue training, and that a new belt at a new grade made the sport more appealing. This system was later adopted into various other martial arts taught throughout Europe, but was also adapted into Karate by Funakoshi Gichin (船越義珍) attempting to increase (Shotokan) Karate's appeal to the Japanese.
Jigoro Kano first came up with the kyu/dan ranks in 1883 for Judo. The original belts were blue (6th kyu), white (5 and 4 kyu), brown (3, 2, and 1 kyu), and black for dan grades (10 ranks). The idea behind the system was to promote a quick reward/progression system and a way to identify your opponent's average skill in randori. After that, a myriad of colours were added.
In Aikido, Ueshiba determined that kyu grades should wear white, yudansha black and those with a Menkyo Kaiden (high level certificate) will be 8th dan.
Note that the black belt is not because either the belt gets died may times or as it getting dirtier and thus looks black. Those are (stupid) myths.
Note as well that other arts such as Muay Thai have a ranking system with colour (in that case arm bands called Prajeat) but they have no common root with the kyu/dan rank system.