Daniel Dae Kim was wide-awake and scrolling through Twitter at 4 a.m. when he realized “The Good Doctor” was going to be a hit.
It was a Tuesday in September, and Mr. Kim, a 49-year-old actor known for his work on “Hawaii Five-0” and “Lost,” found himself in bed in western Bulgaria not far from the set of “Hellboy,” a movie he was filming for release next year.
He had a special interest in “The Good Doctor,” because it represented his first outing in a new role: executive producer. And so, although he had to go to work in just a few hours, he could not keep himself from checking the effusive social-media reaction to the show’s premiere episode on ABC.
When Mr. Kim stumbled onto the “Hellboy” set in the morning, he felt just fine. “I’ve lived with this project since 2013, so one night of lost sleep wasn’t going to make a difference,” he said, laughing.
The tweets Mr. Kim scrolled through that night would soon give way to hard data: ABC’s “The Good Doctor” is the most watched drama on network television. With roughly 17 million viewers for each episode, according to the Nielsen ratings, it draws a bigger audience than the CBS crime show “NCIS” and NBC’s weepy “This is Us.”
The surprise hit has been a boon to ABC, which has been stuck in last place among the big four networks. It also came as sweet relief to Mr. Kim, who had spent three years developing this adaptation of a South Korean show through his 3AD production company.
“The Good Doctor” is a big-hearted medical drama with a twist: The lead character, a brilliant resident played by Freddie Highmore, is autistic. In addition to learning how to become a skilled surgeon, he must figure out how to communicate with skeptical colleagues and confused patients. “What’s the point of sarcasm?” he asks in an early episode.
The show can be soapy and even a little gory. Because the protagonist speaks haltingly at times, onscreen graphics show how his beautiful mind goes at the job of deconstructing a troubled liver or heart.
“This could have been terrible in the wrong hands, or lesser hands,” said David Shore, an executive producer on the series, of Mr. Highmore. “He brings a humanity to this character that isn’t necessarily on the page.”
On Monday, the show will wrap the first half of its improbably successful debut season. For every medical-genre hit like the NBC juggernaut “ER” or the ABC stalwart “Grey’s Anatomy,” there are scores that never make it past season one (Remember “Heartbeat,” “Trauma” or “Mercy?” No one else does, either.)
Mr. Kim took notice of the original version of “The Good Doctor,” an award-winning 20-episode series in South Korea, not long after it started airing in 2013. He scooped up the rights for his new production company and got to work adapting it. Because he was a star of the CBS show “Hawaii Five-0” at the time, he developed it for his home network, which ordered up a script. After taking a look, however, CBS decided against commissioning a pilot.
That is usually the stage when all parties agree to leave a project behind, but Mr. Kim, who was born in South Korea and grew up in Bethlehem, Pa., bought back the rights from CBS. He felt that strongly about it.
He eventually teamed up with Sony’s television arm, which brought in Mr. Shore, the creator of the successful Fox medical drama “House.” Mr. Shore’s version began to attract network interest — although not from CBS.
“CBS actually passed on it twice,” Mr. Kim said. “That was really unfortunate to me, because they were my home studio. I really wanted to bring something home to them.”
Earlier this year, along with his Asian-American co-star, Grace Park, Mr. Kim left “Hawaii Five-0” after he suggested that they had not been not offered salaries commensurate with those of their white co-stars.
“The path to equality is never easy,” Mr. Kim wrote in a Facebook post at the time.
In the end, CBS lost a prime time actor and ABC gained an executive producer who brought it an unexpected hit.
The network needed it. For the last two years ABC has been in last place among the four broadcast networks in the 18- to 49-year-old demographic that is important to advertisers. To make matters worse, Shonda Rhimes, the showrunner behind the ABC hits “Scandal” and “Grey’s Anatomy,” decided to make Netflix her home for all future projects.
Robert Iger, the chief executive of Disney, ABC’s parent company, did not mince words when he described his disappointment with the network earlier this month, saying, “Some improvement from a quality aspect would be helpful.”
Enter, “The Good Doctor.”
The show is partly the result of a programming strategy that ABC hit upon last year, after heartland voters had a strong hand in the election of President Trump — a strategy focused on “not just appealing to both coasts,” said Ben Sherwood, the president of the Disney and ABC television group.
“Roseanne,” the ABC comedy about a working class family that lit up the Nielsen ratings during its nine-season run? Reboot it! “American Idol,” a politics-free singing contest that lasted 14 years on Fox before going off the air in 2016? Revive it! As for other programming, the network decided on a new game plan.
“One of our goals was to move away from cable fare, or living in that dark world of antiheroes,” said Channing Dungey, the president of ABC Entertainment who started last year. “What people are looking for in broadcast is brighter, lighter, more hopeful.”
Indeed, ABC executives and producers for the show are convinced that Dr. Shaun Murphy, the main character of “The Good Doctor,” plays to a wide audience because he is innocent and never meanspirited. While the median age of the show’s viewers is 58, according to Nielsen, it is also popular among teenage girls.
“He’s a hero we haven’t really seen lately,” Mr. Shore said of Dr. Murphy. “He’s overcoming things he was born with. He’s not a drinker. He’s not a womanizer. He’s not an antihero.”
Mr. Kim said it was perhaps a “blessing in disguise” that “The Good Doctor” did not get picked up in, say, 2014, when it may have fallen flat. “There a lot of shows that have a deeply cynical take on the world,” Mr. Kim said. “This is not one of them. Given what I was reading every day in newspapers or seeing on my TV, I felt it was very much needed counter programming to reality.”
Mr. Highmore, the lead actor, came aboard after playing Norman Bates on the A&E series “Bates Motel.” He had a break of only a few weeks between playing a psychotic killer and a good-hearted savant who wants to save lives.
“He always tries to see the good in people,” Mr. Highmore said. “He’s not cynical, he’s not judgmental. In the times we are living in now, having someone with such a positive outlook in the world is refreshing and joyful.”
Whether or not the main reason for its success has to do with the times or the show itself, “The Good Doctor” is ABC’s highest-rated first-year hit since “Desperate Housewives” in 2004 and the best broadcast performer at 10 p.m. in the past 11 years. And now the fourth-place network has something to build on.
“The way to turn a schedule around is brick by brick,” Ms. Dungey said. “What’s very exciting about the success of ‘The Good Doctor’ is that it feels like that’s a very strong brick for us.”