First of all, great question! What you describe here is known as aposematism. Aposematism is the adapation of warning signals against the predator. This word is used for any sound, coloring, and odor used as a warning signal. Of course, for this question the focus is color.
Honest indications
Animal coloration is usually an honest indication of their noxiousness. The brighter they are, the more noxious and toxic they are (http://rspb.royalsocietypublishing.org/content/276/1658/871). In the linked article, there are many references one this positive correlation of toxicity of prey to predator and the brightness of the coloration. In the article they use mathematical models to support the mathemstical evidence. But one thing is for sure: bright colors do mean the prey is armed with defenses, whether the correlation is positive or not.
Why then is it black and yellow?
The conspicuousness of the coloration is very important because it is important to see from a far away distance. The reason colors like yellow and black are used is because (http://rspb.royalsocietypublishing.org/content/279/1728/417):
— They provide high contrast against the background (e.g. red/yellow against green foliage), which promotes detection.
— They are resistant to shadows (which are rich in blue-UV), and to changes in illumination (e.g. black should not change during day, whereas white could become ‘pink’ at sunset and sunrise). Therefore, they provide a reliable signal under varied habitats and light conditions.
— Yellow/red and black has both high chromatic and luminance contrast.
— Such colours may allow distance-dependent camouflage if yellow/red and black ‘blend’ to an average colour that matches the background at a distance when predator vision is no longer sufficient to discriminate individual marking components.
— Such colours are distinctive from profitable species.
What about the combination of black and yellow?
In the same article, they mention that:
Many warningly coloured prey have markings comprising repeated pattern elements. Such arrangements in signal structure may increase redundancy in the signal but improve the likelihood that the strategic component will be detected by the receiver. In addition, repeated elements may be rare in many natural environments, thus increasing conspicuousness of the prey animal. Simple pattern components (such as stripes and spots) may facilitate detection and also speed up avoidance learning if they are easier to memorize.
The research seem to show that the patterns, such as the stripes, lead to increased avoidance, but it is not sure whether or not it is due to the stripes itself or due to the constrast of the black and yellow.
I hope I have answered your question and if you have any questions, feel free to ask in the comments.