Hanlon's razor is a saying that reads:
"Never attribute to malice that which is adequately explained by stupidity."
In simpler words: some bad things happen not because of people having bad intentions, but because they did not think it through properly.
The quotation is attributed to Robert J. Hanlon of Scranton, Pennsylvania, US. According to his friend Joseph Bigler, Hanlon first used it as part of something he wrote for a compilation of various jokes related to Murphy's law. The compilation book was published in 1980 titled Murphy's Law Book Two, More Reasons Why Things Go Wrong. The name was inspired by Occam's razor.
There are many similar sayings. One example is "Never ascribe to malice that which is adequately explained by incompetence." Something similar has been attributed to science fiction author Robert Heinlein’s short story "Logic of Empire" in 1941 (“I would say that you have fallen into the commonest fallacy of all in dealing with social and economic subjects-the "devil theory".'Huh?' 'You have attributed conditions to villainy that simply result from stupidity.”). The phrase has also been erroneously attributed to Napoleon Bonaparte.