Stormtrooper accuracy is something of a joke on the internet. They never seem to hit any important person when they shoot at them, missing constantly. There's a Cracked article on it, for god's sake. Everyone has heard the joke.
It's a complete and total lie, and it ignores the relevant details of the events.
To prove that they are, in fact, crack shots, watch the opening sequence in A New Hope. Here we have a number of stormtroopers charging into a narrow breach into heavy fire, yet they are able to gun down more rebel soldiers in cover than they take in casualties! This is not amateur night here--this is stone cold killers, destroying their foes mercilessly. They are so effective that the defenders fall back almost immediately.
Then, the next time their accuracy is mentioned, it is in the examination of the corpses of a bunch of child-sized aliens. That's right, they were able to kill a number of small targets with expert precision. Now, it was off-screen, but you cannot get that kind of consistency and precision randomly. It beggars the imagination to think that their aim is terrible.
So why can they never hit Luke and Leia in the Death Star? They were ordered not to. The escape was allowed--recall that Tarkin and Vader discussed exactly that the minute the Falcon left. They needed the princess to go to the hidden fortress so they could track them there. She already had refused to give them accurate coordinates, even as her homeworld was destroyed before her eyes. She would never break, never talk. So she had to escape.
Now, killing the one guy escorting her to the ship, or any of the vital crew to the small craft, would be counter-productive to that enterprise. But, they have to make it look good. The escape triggered an alarm. Even if it hadn't (highly unlikely--they command was far too competent at their jobs to let anything slip through), Vader knew that an escape was on--he felt the presence of Obi-wan. Vader is quite competent, and so would have certainly alerted command to this. After all, he did have a discussion about it with Tarkin before seeking out Obi-wan.
The only reasonable conclusion then is that the stormtroopers, fanatically loyal and dedicated to the cause, were ordered to attack but miss when doggedly pursuing these escaping prisoners. And, miss by a small enough margin that it looks good. Recall the bridge scene--blaster fire was erupting around the edges of the doorframe that they were standing on--inches from serious harm. Yet, despite that large volume of fire, in single-shot mode, no hits were scored. And well it was that none did! Had a single shot hit the princess, it could have killed her. It could have wounded her severely enough that escaping with her would have been implausible, and they would have instantly been alerted to the fact that it was a set-up.
It nearly was--Leia thought it too easy. However, any hit would have made it obvious if they did escape, since even if it wasn't lethal, it would have dramatically slowed the party down, destroying any illusion.
As such, from A New Hope, all evidence is that they are, in fact, excellent shots and quite loyal, willing to die for the cause without a moment's hesitation on the order of Lord Vader.
[...]
This leaves the final movie, Return of the Jedi. Again, we see nothing but extreme competency and accuracy on the part of the stormtroopers in battle.
During the battle, we never see the results of their pot-shots against rebels or Ewoks, but we do see them laying down a consistent volley of fire, with disciplined shots, and constant ducking back to cover. One could argue this would mean inaccurate shots, but given the first movie's opening sequence, that is hard to believe. They were using the sights to aim, instead of firing from the hip, during this fight and on the ship combat, they did not bother aiming carefully. It's hard to believe they lose any accuracy at all when using a more carefully aimed approach.
So what direct evidence do we have of their shooting? When Han and Leia are attempting to break into the bunker, two successive pot-shots hit a child-sized object behind partial cover, instant disabling the droid, and inflicting a potentially serious wound on Leia. Again, these were shots taken under hasty aim against targets behind cover, while shots were going towards them. This is not an easy thing--ask an infantryman if you disbelieve me.
The evidence is clear--Stormtroopers are quite accurate and effective soldiers, with top of the line equipment. Claiming otherwise is slander.