I know this was tongue in cheek, but there actually is a potentially viable in universe explanation for why otherwise competent, and possibly even effective Stormtroopers suddenly and spectacularly fail when they are pitted against the characters we tend to follow in Star Wars. The Force itself. Remember, while it doesn't appear to have any kind of consciousness as we understand it, the Force does have a will, and a way of bending events towards outcomes. The Force is most definitely not with most stormtroopers (Finn excluded, obviously). So, we could take it quite literally, that the Force is subtly influencing stormtrooper aim and effectiveness in order to ensure that these agents of the Dark Side are unable to hit targets who matter.
It's an odd thing to think about, but George Lucas basically baked plot armor into the nature of his universe.