Colours in them seem to be used mainly to protect themselves.
Some birds like eating locusts. but birds cannot easily catch them. Why? It is because locusts change their colours together with the change of the colours of crops. When crops are green, locusts look green. But as the harvest time comes, locusts change to the same brown colour as crops have. Some other pests with different colours from plants are easily found and eaten by others. So they have to hide themselves for lives and appear only at night.
If you study the animal life, you'll find the main use of colouring is protecting themselves. Bears, lions and other animals move quietly through forests. They cannot be seen by hunters. This is because they have the colours much like the tree.
Have you ever noticed an even more strange act? A kind of fish in the sea can send out a kind of very black liquid when it faces danger. While the liquid spread over, the enemies cannot find it. And it immediately swims away. So it has lived up to now though it isn't strong at all.