James K explains how colors like this come to be in insects:
Iridescence is the third way to produce color from reflected light, the first two being conjugated double bonds (eg. pigments, dyes) and metal ions (minerals, gems). Iridescence in insects are largely caused by their shell structure that reflect light in ways such that the reflected light rays interfere constructively or destructively (or some combination in between) with each other. As different wavelengths experience different degrees of amplification or cancellation, different colors result, eg. if the blue wavelengths experience cancellation while red wavelengths experience amplification, red will result. There are apparently various ways this can be achieved, such as multilayer reflectors (eg. very thin layers of chitin) and photonic crystals.