Why leaves change color in fall

The bright colors are wonderful to behold. But do they have some hidden purpose?