The Hercules beetle, Dynastes hercules, is able to change its color from a greenish yellow to black and back. How does this occur?
This color changes was investigated by H.E. Hinton and G.M. Jarman*. They discovered that the color was due to the way elytra reflected light. The elytra have a transparent hard top layer and a spongy layer underneath. When the spongy layer is filled with air, the elytra reflect the yellow color. If the spongy layer is filled with water, the light is absorbed and the elytra are black. This process can work on preserved museum specimens as well as live beetles.
Why is color change important? At night when it is moist, the beetle can avoid detection with its all black color. In the daytime when the elytra dry, the color reverts to greenish yellow which is less conspicuous than all black.
*Hinton, H. E. & Jarman, G. M. (1972). Physiological colour change in the Hercules beetle. Nature 238(5360), 160–161.