Shakespeare of course is alluding to the Sun as the "eye of heaven," sometimes shining too hot, and sometimes dimmed. The variableness reflects actual real-world weather conditions. This sonnet, one of his most famous and beloved, has a first line of "Shall I compare thee to a summer's day?" As beautiful as a beautiful summer day may be, he does not necessarily wish to make the comparison with his beloved. -- the sunlight, like the season, is not constant and is quite changeable, and therefore not trustworthy. In fact, his beloved is beyond the beauty of a summer day, because she possesses an "eternal summer," which, being eternal is not variable.
The "eye of heaven" does, indeed, refer to the sun, and the narrator claims that it sometimes shines "too hot." Just as often, its face is "dimm'd," perhaps because clouds have obscured it and hidden its "gold complexion" from view. Both are possible on a summer's day, though summer is often thought to be the most handsome season, and so this is one key reason that the narrator says his lover is more beautiful than such a day. When the sun shines too brightly upon us, it can burn us and make existence quite unpleasant with its heat. However, the speaker's lover is never like this. On the other hand, the clouds might obscure the sun, making for a gloomy and gray day, and this can make life seem quite dull. The speaker's lover is never like this either. Though the sun is inconstant -- appearing to change from day to day -- the subject of the poem is not; she is temperate and lovely, always. Further, one cannot count on the sun because it seems so changeable, and this makes it untrustworthy, but the speaker's beauty never "declines," unlike the sun's. It can be relied upon.