David Milch, the television writer, lives with his wife, Rita Stern Milch, on a peaceful block in Santa Monica, in a cozy stucco bungalow camouflaged by a lush cottage garden. When they moved there, five years ago, from a much larger house a few miles away, where they had raised three children, Milch was about to turn seventy. A survivor of decades of serial addiction-recovery-relapse-recovery—and also of heart disease, childhood sexual predation, obsessive-compulsive disorder, and bipolarity—he remained in command of prodigious gifts. Starting in the early nineteen-eighties, when a former college roommate who wrote for “Hill Street Blues” introduced him to Steven Bochco, the series’ co-creator, and he began writing for the show, too, Milch earned a reputation as one of the most original and intellectually fluent figures in the history of episodic television. In 1993, Milch and Bochco created “NYPD Blue,” a radical reinvention of the prime-time network police drama. He went on to create several shows of his own, among them the sui-generis Western “Deadwood,” for HBO.

Before Milch went to work in Hollywood, he taught writing at Yale while collaborating on a two-volume anthology of American literature with the critics Cleanth Brooks, R. W. B. Lewis, and Robert Penn Warren, who had been a mentor to Milch when he was an undergraduate there, in the mid-sixties. Reading Hawthorne, Melville, Poe, Twain, James, and Faulkner in such depth helped Milch create complex television characters whose voices were each marked by singular diction. His dialogue was suffused with psychological subtext and literary allusion. In Hollywood, his work ethic was undeviating: he showed up every day. He believed, and still believes, that any time spent thinking about writing is wasted except when one is in a room writing. He quotes Billy Wilder: “The muse has to know where to find you.” He also became known for nurturing aspiring writers. Writing and teaching, Milch thought, should be “a going out in spirit.”

I first met Milch in 2004, while reporting about him for this magazine, during the filming of the second season of “Deadwood.” The show, which is regarded by Milch, and by many critics, as his best work, was set in the Dakota Territory in the eighteen-seventies. The town of Deadwood had been at the center of the Black Hills gold rush, one of the last of its kind in the Lower Forty-eight. He began writing the pilot episode only after having spent two years digesting biographies and historical accounts of mining, the Indian wars, territorial politics, whorehouse and gambling protocols, rudimentary systems of justice, and criminality mundane and monstrous. Deadwood, built on land stolen from the Lakota Sioux, had attracted exiles, fugitives, optimists, gamblers with nothing to lose, bloody-minded opportunists, cynics, and seekers who had come to try their luck, or to escape bad luck, in terrain that lay largely beyond the reach of the law.

The real people depicted in “Deadwood”—among them Wild Bill Hickok; his murderer, Jack McCall; Calamity Jane; Wyatt Earp; and Al Swearengen—are greatly outnumbered by Milch’s fictional characters. Through three seasons of labyrinthine story lines, an ever-rising body count, boundless scheming and exploitation, and a profusion of depravity that sometimes abruptly transmuted into tenderness, Milch’s dialogue transformed the frontier demotic into something baroquely profane. In an early episode, a prospector named Ellsworth, having breakfasted on a few shots of whiskey, declaims to no one in particular, “I may have fucked up my life flatter ’n hammered shit, but I stand here before you today beholden to no human cocksucker, and workin’ a payin’ fuckin’ gold claim, and not the U.S. government sayin’ I’m trespassin’, or the savage fuckin’ red man himself or any of these other limber-dick cocksuckers passin’ themselves off as prospectors had better try and stop me.”

By design, Milch wrote “Deadwood” under a gun-to-the-head deadline, regularly composing dialogue the day before a scene was to be shot. Milch is the only writer I have ever watched, at length, write. I sat in a dimly lit, air-conditioned trailer as Milch—surrounded by several silent acolytes, of varying degrees of experience and career accomplishment—sprawled on the floor in the middle of the room, staring at a large computer monitor a few feet away. An assistant at a keyboard took dictation as Milch, seemingly channelling voices from a remote dimension, put words into (and took words out of) the mouth of this or that character. The cursor on the screen advanced and retreated until the exchange sounded precisely right. The methodology evoked a séance, and it was necessary to remind oneself that the voices in fact issued from a certain precinct of the fellow on the floor’s brain.

In June, 2006, at the start of Season 3, HBO announced, unexpectedly, that there would be no Season 4. Instead, the network said, Milch would bring “Deadwood” to a conclusion with a pair of two-hour movies. Within months, it became evident that even this was not to be. Rather than being permitted a meticulously conceived dénouement, “Deadwood” just stopped. It came as a gut punch to everyone associated with the series. “Deadwood” devotees never abandoned hope that it might someday return, but the more time passed the less likely a revival seemed. The show had sinned by failing to rack up the boffo audience numbers sufficient to convince HBO that it would become a sensation, like “The Sopranos,” which was winding down after six seasons.

Still, the studio’s faith in Milch never wavered. It just wanted him to focus on more potentially lucrative projects, and persuaded him to create a new series, “John from Cincinnati,” set in a California surfing community, a collaboration with Kem Nunn, a novelist whose books can be found in the surf-noir section. It lasted only one season, a consequence generally attributed to a plot-coherence deficit. In the years that followed, Milch remained fiercely industrious. He created “Luck,” set at the Santa Anita Park racetrack and starring Dustin Hoffman, which was shut down in its second season after multiple horses died during filming. Milch also made a pilot—the only episode shot—for an HBO series called “The Money.” (Milch described it to me as “King Lear meets Rupert Murdoch and family.”) Two other HBO projects never progressed beyond the pilot-script stage: adaptations of Peter Matthiessen’s novel “Shadow Country” and “Island of Vice,” a history of Theodore Roosevelt’s tenure as the police commissioner of New York City. Earlier this year, HBO’s “True Detective” aired a new episode written by Milch and Nic Pizzolatto.

Milch’s career earned him a fortune—more than a hundred million dollars from “Hill Street Blues,” “NYPD Blue,” and “Deadwood” alone. This made possible both a history of philanthropy and promiscuous nondeductible one-to-one largesse. Several years after I published my Profile, as Milch was writing early episodes of “Luck,” he called and tried to persuade me to work on the series. I reflexively declined the offer. He kept at it, and I kept demurring. At last, he said, “Let me just send you some money.” To Milch I owe the strange pleasure of once upon a time hearing myself say, “Please do not send me money.”

Unfortunately, this tendency to treat money as something to be gotten rid of also fed a gambling compulsion, which controlled Milch as unremittingly as heroin, alcohol, and pain meds once did. A 2015 lawsuit in Los Angeles Superior Court, filed by Rita Milch against David’s former business managers, revealed that between 2001 and 2011 he lost almost twenty-five million dollars betting on horses and football. (The lawsuit was settled out of court.) Only when Rita learned—from the business managers, in 2011—of their calamitous finances did David’s gambling cease. They owed the Internal Revenue Service five million dollars. Both their houses—in Brentwood and on Martha’s Vineyard—went on the market. Rita sold much of her jewelry. The bungalow in Santa Monica is a rental.