George Sr.: Don't worry, Michael. [conspiratorial whisper] They can't convict a husband and wife for the same crime! Michael: Yeah, that's not true. At all. George Sr.: Really? ...I have the worst f---ing attorneys.
At a less enlightened point in legal history, a woman's legal identity was overtaken by her husband. One of the results of this, when mixed with another old legal concept (you could not testify at your own trial), was that a wife could not testify for or against her husband. As the rules regarding legal personage and testimony changed, this turned into a rule that one spouse could not give adverse testimony against the other. Over the course of the 20th century, this rule has continued to change, generally transforming into a sort of privilege for certain communications.
Currently, in U.S. federal courts (other nations' courts and State courts frequently have a different, typically lesser, degree of protection), two spousal privileges exist:
Marital confidences privilege: Any private conversation between spouses during the marriage, even if the two are later divorced, is not admissible as evidence, unless both allow its admission.
Spousal testimonial privilege: If one spouse is on trial, the other cannot be compelled to testify against the one on trial. "Compelled" is important here; if one spouse wants to, say, sell the other out to the cops, the spouse is free to do so (note that this is considerably different from other sorts of legally recognized privileges. In those cases, the party the information is adverse to has the control.) Unlike the Marital confidences privilege, the two have to be married at the time, but this privilege also covers things before marriage.
If they are on opposite sides of the lawsuit, such as in divorce proceedings, child custody, or when one is the plaintiff and the other is the defendant, all spousal privilege is suspended.
When this is used in fiction, it tends to be ... broadly used to say that the other spouse can't be a witness, whether he or she wants to or not.
Used as the Twilight Zone Twist in one The Twilight Zone comic. A man who sells his soul for with the understanding that he must be a horrible person. When he dies, he goes to Hell, the Devil requires him to prove that he has been a horrible person. He calls his wife, whom he has abused terribly, as witness to his awfulness. However, she smiling says that a wife cannot be compelled to testify against her husband, and the man is dragged off protesting by demons.
There is a Luke/Mara fanfic, where the New Republic wants to prosecute Mara for her crimes while serving as Emperor Palpatine's agent. Their only witness is Luke. Now, being a Jedi Master, he's not supposed to lie... so he marries her, and thus gains the right not to testify.
In Angel Face (1952), Diane Tremayne conspires with chauffeur Frank Jessup to murder her parents by tampering with their car. Both Diane and Frank are arrested for the deaths, but they get married so they cannot be made to testify against each other.
In A Song Is Born, Gangster Tony Snow wants to marry his moll girlfriend Honey Swanson just so she can't testify against him about a murder he committed.
In the Perry Mason book The Case of the Curious Bride, the defendant's husband has damaging testimony against her. His family does not approve of her, so they're trying to get the marriage annulled so his testimony will be admissible.
In the Sidney Sheldon novel "Master Of The Game", Keith blackmails Eve into marrying him by revealing that he knows she killed George Mellis (as revenge for brutally assaulting her several years prior). When he tells her that if they were married, he couldn't be forced to testify against her, she reluctantly agrees, but is infuriated when she realizes that they have to stay married—there's no statute of limitations on murder.
In ''The Sopranos, Adrianna gets this idea from a late night crime show and proposes to Christopher so she can't testify against him. Unfortunately, some clarification from an actual lawyer points out the flaws in this plan.
One episode revolves around the concept that two villains had married their victims precisely to abuse spousal privilege, something with which they openly mock the detectives. Their overconfidence eventually backfires when investigations dig up a prior marriage license they hadn't gotten annulled, making their current marriages null and void.
Another episode involves a serial rapist giving trophies from his victims (usually, jewelry) as gifts to his wife. He would ask her to wear the gifts during sex. She thought nothing of it until presented with all the evidence of the rapes. She agrees to testify, but is forbidden from giving any details regarding what her husband would have her do with the gifts, as the defense attorney argues that giving gifts to a spouse counts as private communication and is inadmissible as evidence. The prosecutor is limited to asking only details as to when and which gifts were given. During the trial, the wife gets upset that she's not being asked more and breaks down, revealing the truth. The judge declares a mistrial, and the husband goes free, until one of his earlier victims helps his wife shoot him "in self-defense".
The Closer used variations on both types, on different occasions.
In the first instance, the wife claims spousal privilege so she can't be forced to testify against her husband, which Brenda tells her doesn't apply in this case, though in the end she testifies of her own will as part of a plea deal, as she had committed the murder at her husband's instigation.
In the second instance, the wife, after being told that her husband is a war criminal and likely murderer, she, in a state of shock, relates how her husband came home covered in blood (which she presumed was from the assault on him), then invoked spousal privilege and told the police they couldn't act on the information in that conversation. Brenda complies, and tries to find probable cause to search for traces of blood, but in the end, they get around the spousal privilege by establishing that the husband used a fake name on his marriage certificate, thus nullifying the legality of the marriage and spousal privilege.
Invoked in Downton Abbey, where Anna is forced onto the sidelines at Bates' trial.
In Boardwalk Empire, Nucky marries Margret partly so she cannot testify against him in his trial for the murder of her first husband.
In the Castle episode "Den of Thieves", they interview the wife of Esposito's allegedly Dead Partner, whom they suspect of the murder of the week. She points out that either he's really dead, in which case he didn't do it, or he's not, in which case they're still married and she can't be compelled to testify against him.
Both POIs of the Person of Interest episode "Till Death" invoke this at the end. This was unusual in that the crime that they were arrested for was hiring hitmen to kill each other.
In Breaking Bad, Skyler opts to go back on her desire to divorce Walt when she devises a cover story for his drug money so that it can go towards Hank's physical therapy, claiming it's so they can't be compelled to testify against one another.