The prevalence of this trope results from a lot of confusion about the use of the word "insane".
Insanity strictly speaking has a clinical definition and a legal definition. Without getting into what those two definitions are, the point is there is a subtle difference in its usage. The clinical definition largely deals with a mental condition that can be treated and cured by providing therapy. The legal definition, and this is the complicated one, deals with whether a person who is clinically regarded as insane can be held accountable for his actions. The intersection of these two definitions leads to the social discourse on insanity.
Depending on the nature of the crime, but say its a crime of murder or serial murder, legalists, political pundits and all sorts of independent voices wonder if it is justice to send them to a hospital as a patient rather than treat them as normal criminals and provide justice to the families of victims. It is this discourse that underpins the usage of this trope. By making villains to be sociopathic and murderous, as well as cunning and savvy enough to hijack and co-opt the bureaucracy and machinery of mental treatment for their own ends, the trope implies that insanity is both incurable and dangerous to society.
Despite this implication, one shouldn't see writers and artists as necessarily in conspiracy against the mentally ill. Ever since psychology took root in the Western World, and the United States in particular in the 50s through 70s, it has inspired several popular books that look at crime from a psychological and sociological perspective. The books "The Lonely Crowd" and "One Dimensional Man" in particular struck a chord in the 50s about how post-war society created a society of alienated, isolated individuals who no longer had a real community. The initial use of this trope was to make villains sympathetic. Rather than seeing them as moustache-twirling bad guys, by stating that they were mentally ill and should be pitied/understood, the idea was to look at criminal behaviour in light of a larger social context. Norman Bates in Psycho is a good example. In the original book by Robert Bloch, based on the Ed Gein murders, Norman was fat, ugly and unlikable. Hitchock however felt it would be more surprising if Norman was a handsome and likable boy next door whose Mommy Issues made him go insane. This later became a cliche, but at the time was quite shocking for suggesting that a classically 50s Kid raised in rural America could melt down in that fashion.
As in the case of all new ideas, they become cliche in time. The disillusionment in the 60s in the wake of the Manson Family murders led to a backlash against this trope. The horror and slasher-film genre that came afterwards still worked in the same spook-show manner of old stories but in order to cater to new audiences made the villains to be psychopaths, while still having them perform the same function as a scary woods monster and other elements from older stories. This introduced psychopaths like Hannibal Lecter where the craziness becomes a quasi-superpower and a new characterization of Joker on the same order, while at the same time, weirdly enough, being entertaining on account of their neuroses which explains why these characters tend to be regarded as Draco in Leather Pants by some of the fans. As such Insane Equals Violent as a trope is not without its element of exploitation or carnival freak show aspect. It somehow caters to the fascination with a character because he's insane and violent and remains insane and violent, the minute real world logic and realistic psychotherapy intrudes itself on the story, the characterization and fascination dies with it.