The answer to this question would basically be the same as to ‘why are any flowers this or that color or shape’. And the answer is – to attract certain kinds of pollinators who would move from one flower to another, spread the pollen and help the flowers reproduce. And the kind of pollinators the flowers need to attract depends on geography and climate zone of the flower. Sunflowers are native to North America. Common pollinators there are honey bees, butterflies, hummingbirds. The yellow color of the petals attracts them and the large surface of the flower itself provides a comfortable landing.