Why are flowers colored?
Petals are colored to attract insects.
Flowers have colorful petals, especially in those plants which are insect pollinated attract insects. While the insects suck out nectar, stamens rub against insects' body. As this happens, pollens stick to insects' bodies and get transferred to the next flower they visit.
The above Image depicts sticking of pollen grains to the body of a bee.