BJJ borrowed its belt system from judo.
History of the belt system
Kano Jigoro, the founder of judo, introduced the gi and belt ranks to his students so practitioners could track their progress. The belt system in Brazilian jiu-jitsu is similar, with a few differences.
Judo reached Brazil in 1914 through Mitsuyo Maeda (also known as Count Koma).
The Gracie family later helped standardize the BJJ belts.
Why the system exists
The belt gives a clear, quick read of someone's level and the techniques they're likely able to execute, for both practitioners and instructors.
It also builds camaraderie. A higher belt is motivation to keep training so you can earn that rank yourself. A lower belt is a reminder to be humble and help the newer people.
Adult BJJ belts
The International Brazilian Jiu-Jitsu Federation (IBJJF) is the largest and most prestigious BJJ organization in the world. It recognizes six ranks for adults: white, blue, purple, brown, black and red. The red belt is reserved for those who have mastered BJJ and put real effort into spreading it around the world. That leaves five belts that are realistically achievable.
White belt

A white belt is new to the art and learning the basic techniques and principles. White belts should concentrate on escaping mounts and submissions, since they'll spend much of their early career in unfavorable positions.
Blue belt

A blue belt has a good grasp of the basics and is starting to develop their own style. Blue belts refine their techniques and build a game plan. A blue belt must stay at blue for at least two years before promotion.
Purple belt

A purple belt is experienced and has a strong personal style. Purple belts perfect their techniques and keep developing their game plan. The IBJJF requires students to be at least 18 years old and recommends a minimum of 18 months at purple to be eligible for brown.
Brown belt

A brown belt is an advanced practitioner with a well-rounded game, who can start teaching lower-ranked students. The focus is staying in shape and refining skills. The IBJJF requires brown belts to stay brown for at least one year before black.
Black belt

A black belt is the highest rank you can realistically earn in BJJ. It signals a deep understanding of the techniques and principles, and usually many years of training and competing at the lower belts.
Black belts are often tied to the lineage of the fighter's instructor, and the IBJJF black belt is the most common.
Many black belts become instructors and pass their knowledge on to the next generation.
Red belt

The red belt is the highest rank in BJJ, and there are very few. A red belt must already hold a black belt and have trained for many years, and red belts are highly respected in the martial arts community. They focus on continuing to promote the art.
Practitioners who have reached it include Carlson Gracie and Rickson Gracie.
How many red belts are there?
The Gracie family has the most, with names such as Carlos Gracie Sr (10th degree red belt) and Hélio Gracie (10th degree red belt).
You can learn about red belts in more detail in this article.
How to get promoted
Promotion usually depends on time spent training, proficiency in techniques, sportsmanship and competition results where applicable.
The specifics vary by academy, but there's typically some kind of testing or evaluation first. Some academies, for example, require a written exam on the material covered before you can test for your next rank.
BJJ belt stripes
An instructor awards stripes when a student shows progress in skill and knowledge. They usually come at regular intervals (every three months, say), though that depends on the school. Some schools also require a specific goal, such as successfully completing a difficult technique.
Each belt has four stripe positions, so a student can have at most four stripes at a time. Stripes are usually sewn on by the instructor, though some schools let students do it. The most common method is to stitch them onto the end of the belt.
There's no standard size or shape. They can be any color and are often made from simple materials like cloth or ribbon.
The black belt doesn't have stripes but degrees, and all promotions after that are more formal. Stripes aren't required to take part in BJJ, but many people enjoy working toward them as a way to track progress.