In Hex there are 16 relevant characters that make up the numbering system. This is also called a base 16 numbering system. You can convert between decimal and hex fairly easily. In hex, You will only need 6 digits to represent a color code, because the number represents all the possible combinations of color codes. This relates directly to how computers store numbers, specifically how big each number can be per a unit of memory.
Most computers have a standard unit system for storing information.
This is a byte. There are 256 possible combinations of bits in a byte. Each Hex digit corresponds to 4 binary bits, this means that 2 Hex digits can represent 8 bits. As you can see, Hex can be used to easily represent bit patterns. The reason Hex is used most often is because it can represent large numbers in a visually compact format.