1. The energy comes from sunlight.

2. The energy comes from the sunlight.

(Which one is right? Do we have to use 'the' or not?)

No need for "the" in this sentence. Sunlight is one of those non-count nouns, so "the" is not correct here.

http://grammar.ccc.commnet.edu/grammar/noncount.htm