Theoretically, the Empire may have developed some form of cockpit windows that would appear dark from the outside, yet could be seen through on the inside. Shielding from cosmic radiation might be why. Of course, that raises the question of how the rebels survived in their space ships with no shielding... presumably the rebels wouldn't have access to better technology than the empire.
In truth, this is a dramatic tool used by Lucas. The good guys are open and visible, while the bad guys are not visible, and therefore, not quite human in the mind of the viewer. It's a good example of the subtle touches a film director uses to create a mood in the mind of the viewer. Vader with his Nazi inspired helmet, the storm troopers being completely covered while all of the rebel forces had their faces visible are other examples of this implied dehumanization of the opposition.
True that the TIE fighters appear to have clear windows, but they are so small that you almost never see into them from the outside, while the X and Y wing fighters have the good guys prominently displayed and definitely visible. You do see a few shots of operators inside the TIE fighters, but they're completely covered up, and thus less human.
Note also that this particular shuttle is the only one that gets a name, making it appear slightly more 'friendly' to the viewer. None of the empire ships, not even the big ones, are ever referenced by a specific name in the first three films, thus dehumanizing the empire more. Just this one lowly shuttle that just happens to have good people on board. (you'd think that might have been a clue to the empire forces around Endorn... something suspicious about that shuttle that has a name...)
Even the death star doesn't have a specific name, it's just the Death Star. You'd think they might name it the Death Star Palpatine, or something like that... This enhances the 'individual effort versus anonymous giant collective' theme that plays out in the first three films... remember that all were made when the communist USSR was the major opposition in real life, so this plays to the 'individual hero versus rigidly controlled collective' theme that permeated much of the capitalist versus communist conflict.
Imagine Han Solo flying a cargo ship with no name, just a model designation. Wouldn't be nearly as memorable a moment if Han had said on Hoth: "never mind, I'll get her out on the piece of junk".
Note that this isn't the first time that Lucas used subtle touches to enhance the difference between bad and good. In American Graffiti, bad guy Bob Falfa's 55 Chevy was black, while John Milner's deuce coupe was yellow, and Richie Cunningham's Buick was white.
Edit: on further reflection, there would be a scientific reason for the blacked out cockpits. If you go back and review the film 2001, probably the most realistic fictional space scenes ever put on film, you find that the spacecraft, viewed from the outside, have very bright exterior illumination with very black shadows. Until the camera got close, the cockpit of the lunar shuttle appears to be dark when viewed from the outside.
Or, if you look up some of the actual Apollo films of the LEM when it was near the CSM, you find that the windows appear to be blacked out, until the two craft get very close.
The reason for this is - no atmosphere, no sky, and therefore no backscattering of the sunlight to illuminate shadows. It's why the space scenes in 2001 have that stark, sterile look to them. That's what spacecraft actually look like in space.
Keep in mind that most science fiction films are done with entertainment in mind, they present a fictional story with familiar cues... as in spacecraft that are illuminated like airplanes in flight because we're familiar with airplanes in flight, and even tend to fly like airplanes in flight while there's no atmosphere. They want you to understand the story, not struggle with something you might not quickly comprehend.
Kubrick went for the ultra realistic space cinematography (in 1968, mind you, when there were very few films of actual spacecraft in space), because it made the familiar unfamiliar to the viewer, and thus made it seem more realistic. Then again, 2001 wasn't your typical sci-fi film.
However, this would apply to all ships in space, not just the bad guys. So, yes, there is a reason cockpits on spaceships might appear dark... no atmosphere to backscatter the sunlight, and what little light that's inside would be overwhelmed by direct sunlight, especially if the spaceships are operating near a class M planet (as they usually are in the SW scenes) where sunlight is fairly bright.
As for why the rebels could be seen in their cockpits... either they had massive floodlights installed inside to match ambient sunlight, or the director was using that technique to enhance their good guy nature.