Why does plant life precede the Sun in the order of creation given that plants need the Sun to do photosynthesis?
First, it may not be valid to assume that creation was bound by the laws of science as we now understand them. Why should we assume that the very first plants grew by photosynthesis in the same way that plants do now? Or if we do, why not assume that the primordial light created on the first day was enough to produce this effect?
But setting all that aside, Bereishit 2:5 presents us with a related question:
Now no tree of the field was yet on the earth, neither did any herb of the field yet grow, because the Lord God had not brought rain upon the earth, and there was no man to work the soil.
It's not clear when this text refers to; it falls after vay'chulu and and before the (second) creation of Adam. This verse seems to say that plants depended on man being available to work the soil. But chapter 1 says we got plants on day 3, so how do we resolve this? Rashi offers the following interpretation:
neither did any herb of the field yet grow: [I.e.,] had not yet grown. And on the third [day], where it is written: “Let the earth bring forth,” they [the plants] had not yet emerged, but they stood at the entrance of the ground until the sixth day. And why?
Because… not caused it to rain: Because there was no man to work the soil, and no one recognized the benefit of rain, but when man came and understood that they were essential to the world, he prayed for them, and they fell, and the trees and the herbs sprouted. — [from Chul. 60b]
According to Rashi, when God created the plants, trees, and grasses on day three, they didn't actually start growing -- they were, essentially, "queued up" underground, waiting for rain, which in turn waited for a man to recognize the need for rain and pray for it.
With Rashi's interpretation, the sun, moon, and stars were well-established before the need for photosynthesis arose.
Ralbag has two explanations of the order of creation that can address this. The first explanation is that everything existed at once. The sequence delineated in Genesis is just the order in which they were revealed. This is likened to someone who plants various seeds at the same time but some sprout before others. The second explanation is that existence is attributed to some things before others in order to show their priority in essence and cause (i.e. the sequence is not meant chronologically).
והנה המשילו החכמים הגלות ההויה בקצת הדברים קודם קצת במעשה בראשית למי שזרע זרעים חלוקים יחד בארץ ויצמחו קצתם קודם קצת וכן אמרו שהיה הענין בהוית העולם שהכל נתהוה יחד מהשם יתע' ונגלה קצתו קודם קצת או נאמר שכבר נתיחסה ההויה לקצת הדברים קודם קצת להעיר על היותם קודמים בעצם ובסבה כי כונת התורה היא להעמידנו על חכמת הנמצאות בזה הספור הבפלא כמו שקדם
(See also his similar discussion in Wars of the Lord ('מלחמות ה) Book VI Part 2 Chapter 8.)
R. Abraham of Vitirbo (Sefer Emunas Chachamim Fifth Essay)applies the general rule of "ein mukdam u'meuchar b'torah" to the account of creation, in which case the sequence of six days does not necessarily represent the true chronological sequence.
ויש מן הפילוסופים שהקשו כי היאך נתהוה האור ביום הראשון והלא עדין לא נבראו המאורות ולאו קושיא היא כי אין מוקדם ומאוחר בתורה
On the initial premise of plants requiring the sun for photosynthesis, and it certainly is the best light for developing plants, this site reports how scientists developed plants WITHOUT anything but artificial light.
As for the light before creation, see Alex's great answer here where he discusses the gemara Chagiga (12a) saying "the light created on the first day is the same as that we get from the sun and other heavenly bodies. The verse tells us G-d created them on the first day, and then placed them in their proper positions on the fourth day." Consequently, the plants would presumably have the necessary light energy to survive and thrive. More on this light can be seen here.
Obviously it is the case of textual corruption. Some verses got mixed up. The Sun and the Moon had to be created before the trees and grass because the latter can't grow without the former.
Here is how I think original text looked like:
Bereshit 1:9 And God saith, 'Let the waters under the heavens be collected unto one place, and let the dry land be seen:' and it is so.
Bereshit 1:10 And God calleth to the dry land 'Earth,' and to the collection of the waters He hath called 'Seas;' and God seeth that it is good.
Bereshit 1:14 And God saith, 'Let luminaries be in the expanse of the heavens, to make a separation between the day and the night, then they have been for signs, and for seasons, and for days and years,
Bereshit 1:15 and they have been for luminaries in the expanse of the heavens to give light upon the earth:' and it is so.
Bereshit 1:16 And God maketh the two great luminaries, the great luminary for the rule of the day, and the small luminary--and the stars--for the rule of the night;
Bereshit 1:17 and God giveth them in the expanse of the heavens to give light upon the earth,
Bereshit 1:18 and to rule over day and over night, and to make a separation between the light and the darkness; and God seeth that it is good;
Bereshit 1:13 and there is an evening, and there is a morning--day third.
Bereshit 1:11 And God saith, 'Let the earth yield tender grass, herb sowing seed, fruit-tree (whose seed is in itself) making fruit after its kind, on the earth:' and it is so.
Bereshit 1:12 And the earth bringeth forth tender grass, herb sowing seed after its kind, and tree making fruit (whose seed is in itself) after its kind; and God seeth that it is good;
Bereshit 1:19 and there is an evening, and there is a morning--day fourth.
Since MT=SP=DSS it means that the change occurred before 2nd Temple period.