At the end of March, The Good Wife writers tweeted that Sarah Silverman was set to guest star on the CBS drama, and last night saw the fruit of that casting in the episode “Getting Off.” In a turn from her comedic roots, Silverman played Stephanie Engler, the purveyor of a controversial adult website that brokered hookups between married people. Lockhart/Garner defended the woman against the disgruntled wife of a man who was murdered after using the website. Considering that Silverman is famous for envelope-pushing jokes, how’d such interesting casting come together in the drama?

“We’re Sarah Silverman acolytes,” says Robert King, who created The Good Wife with his wife, Michelle. “We love her. And so we basically said, ‘Can we find a gap in your schedule?’” As you might guess, however, Silverman’s role wasn’t initially set to be so dramatic.

“Originally we were doing an FCC episode where it was going to be a comedian who sues the FCC, and we kind of wanted to see if she would be available for it and timing worked out, but I don’t think her interest was in playing a comedian,” Robert explains. “So we had this other idea – the writers had this other idea that we pitched her and she was into it.”

The nature of the show – which sees guest stars, both clients and judges, abound in its courtrooms – allows for such changes as the storylines develop. “The show is very flexible in that you can have different clients, you can have different judges, and what’s wonderful is to have strange people pop up in roles that you wouldn’t imagine,” Robert says. “Our schedules on each episode are eight days, guests come in for four or five days and do an arc and then they leave. So we pitched her that and she was excited, I think.”

Were the Kings pleased with her performance in last night’s episode? The short answer: Yes. “She has a very good monologue,” King says. “I mean probably the longest piece of writing written on the show, which was this monologue about desiring men and it was really – she did such a very good job with it. I’m glad she tried something dramatic because I think it can just add to the comedy, too.”

Check back next week on EW.com for our interview with The Good Wife’s creators on the show’s highly anticipated season finale.