This is called aposematic coloration. I showed an example of a red frog with blue legs, and I advised the class not to eat anything quite so pretty. In his original papers on kin selection, Hamilton suggested that kin selection might assist the evolution of aposematic color, since color that makes the animal conspicuous would make it easier for a predator to detect the animal, and would be a disadvantage if the predator had not already learned to associate the pattern with a bad taste experience. But, an individual that helps to educate a predator will increase the survival of others with the same pattern. The advantage of bold color patterns to advertise unpalatability is that predators remember them more easily.
Mimicry evolves when organisms derive protection from attack by resembling different species.
In Batesian mimicry, named after the 19th century naturalist H E Bates, an edible species is protected by mimicking an aposematic species. I showed slides of a spider that resembled an ant and a moth that resembled a wasp. For example, the head of the moth still looked like a moth's head, not a wasp's head. The antennae of the fake ant were the front legs of the spider and if you looked closely you could see that they were attached in the wrong place to be real antennae. Mullerian mimicry involves resemblances between different distasteful species.