Warning colouration

Warning colouration (or aposematism) is how animals let other animals know that they are poisonous or dangerous. It is the exact opposite of camouflage. Warning colours are usually some combination of red, yellow, black and white.
Alfred Russel Wallace, a British naturalist, explained it this way, in 1889:
Wallace predicted that birds and other predators would reject conspicuous prey whilst accepting cryptic prey. Later reports confirmed this.
Animals with warning colours move slowly and expose themselves to sight. The sluggishness and exposure helps to advertise their defence. Along with the colour and behaviour often goes the foul smell of their chemical weapons. The grasshopper "Aularches miliaris" is a very good example. Noxious caterpillars often have thick, leathery cuticles which help them to resist young birds making a 'test'. When the bird takes a peck, disgusting fluid seeps out from special glands on its back. The caterpillar (or other larva) will often survive such an attack, and the young bird has learnt a lesson it will never forget. All in all, the predator is given good warning. Tests show that warning colours definitely do deter predators.
Some individual animals will die or receive damage while birds or mammals on the attack learn about the connection between colour and taste. However, if warning costs less than hiding, the animal benefits. And the advertising traits such as colours may serve other functions as well. The patterns may help mate identification within the species, for instance.
Warning colouration is the basis of two different kinds of mimicry: Müllerian mimicry and Batesian mimicry.
Toxin resistance.
There are a number of predators which eat toxic animals. Cases which have been studied suggest there is some kind of cost to be borne for their relative immunity to the toxin.
The rough-skinned newt is toxic, and displays its warning colour by showing its abdomen. Throughout much of the newt’s range, the common garter snake ("Thamnophis sirtalis") is resistant to the toxin. In several populations, these snakes successfully prey upon the newts. Toxin resistant garter snakes are the only known animals that can eat these newts and survive.
The snake’s resistance to the toxin has resulted in a selective pressure that favours newts which produce more potent levels of toxin. Increases in newt toxicity then causes a selective pressure favouring snakes with mutations conferring even greater resistance. The price paid by the snakes is that their digestion and body metabolism is slower than related species. Really resistant snakes have slower crawl speeds than snakes with little or no resistance.
This is an example of co-evolution. This cycle of a predator and prey co-evolving is sometimes called an evolutionary arms race. In this case it results in the newts producing levels of toxin far in excess of what is needed to kill any other conceivable predator.
Bright colours.
Animals can, and do, show bright colours which have other functions. The most common functions are:
However, the bright colours used for these functions tend to be different from the standard warning patterns and colours. 
Unknown function.
The colouring of many species has unknown function. This is usually because their life habits have not been studied sufficiently, and because no field tests have been done. One example is the moth "Utetheisa pulchella", the crimson speckled moth. Its association with the plant "Dittrichia viscosa", which has a somewhat unpleasant smell, suggest the moth has warning colouration, but the matter is not settled. The related species "Utetheisa ornatrix", which feeds on other plants, is known to exude (squeeze out) alkaloids to put predators off.