A Twinkie Defense is a legal argument that a defendant in a criminal case was acting with diminished capacity due to a biological factor at the time of the crime. It is certainly possible for a biological factor to have an impact on someone's behavior, but in the case of a Twinkie Defense, the factor is usually deemed spurious. For example, someone who claims to have been seized with a fit of rage after drinking three cups of coffee might not be taken seriously in court, while someone who suffers from mental illness might be considered for a diminished capacity defense.
This slang term has its origins in the 1979 murder trial of Dan White, a former San Francisco Supervisor who shot the Mayor of San Francisco and another Supervisor in cold blood in 1978. Many people mistakenly believe that White's lawyers claimed that the popular snack food had driven White insane, leading him to shoot George Moscone and Harvey Milk. In fact, Twinkies were never actually specifically mentioned, although other snack foods were.
In the Dan White trial, snack food wasn't used to explain his behavior, but rather to illustrate it. The defense wanted to show the jury that White had been sinking into depression, and they thought that his increased junk food consumption in the months leading up to the murder was a solid piece of evidence that a former health-food nut had been experiencing some mental problems.
San Francisco newspapers were the first to popularize the idea of the “Twinkie Defense,” despite the fact that the term doesn't really apply to the trial which inspired it. Despite this, the term has caught on, and it can be seen used in reference to a variety of legal cases when the defense tries to argue for diminished capacity. "Twinkie Defense" also makes for good headline fodder, which might explain why this slang term has endured so long.
A related concept, transpanic, references claims made by defendants accused of murdering transsexual individuals. According to these defendants, the shock of discovery the true identity of the victim was so intense that they lashed out instinctively; “gay panic” is a similar claim involved in murders or assaults on homosexuals. Many activists feel that gay panic and transpanic are examples of a Twinkie Defense, arguing that people act out of anger in these cases, but that their capacity to judge right and wrong are not at all diminished.