What would be the purpose of using a colour code for resistors instead of just printing their values?
A long time ago, the technology did not exist or was too expensive to print such small text on parts.
Also, you can read coloured rings no matter what angle you are looking at the resistor from or how it is mounted, but as someone who has trouble telling similar colours apart this is useless and I don't really buy it.
Some leaded resistors, particularly precision ones, are marked with the value.
Putting color bands on the resistor allows the value to be read regardless of the orientation, and very quickly for a skilled person.
Once you go to more modern surface mount parts, it is more common than not to have the resistance value simply printed on the top for the larger (and thus more human solderable) sizes:
Through hole parts don't do that because they're old and in the old days precision manufacturing wasn't as good as it is now.
Surprisingly, this (edit: labeling) never caught on for capacitors (edit: SMD capacitors), even though resistance is much easier to measure.