Republicans face long odds in the race to fill the congressional seat left vacant by the death of Rep. Elijah E. Cummings (D-Md.), and perhaps no one knows that better than the eight who have signed up to try.

Why take on the improbable in a state that tilts heavily to the Democratic side? Or in a district where Republicans are outnumbered about 5 to 1?

Political parties have their reasons for wanting candidates to run in every race no matter the odds. But the calculus for candidates who set off on a quixotic mission is often personal and varies as much as they do.

“I serve the God of miracles,” said Liz Matory, a D.C. native, Ivy League graduate and former Democrat. Her website says that she was the first African American woman nominated by the state’s Republican Party to run for Congress — a reference to her unsuccessful bid against Rep. C.A. Dutch Ruppersberger (D) in 2018.

“I know a traditional Republican couldn’t win it,” Matory, 39, said of the special election to serve out the rest of Cummings’s term. “But I could.”

Matory would first need to get past an energetic field of other Republican primary contenders, including Kimberly Klacik.

Klacik, who is also African American, comes to the campaign with some name recognition after frequent appearances on Fox News and other conservative media. She boosted her star power last summer after posting video on social media that depicted West Baltimore as a dump and grabbed President Trump’s attention. Trump, in a now infamous series of tweets, called Cummings’s district a “disgusting, rat and rodent infested mess” and said “no human being would want to live there.”

While critics called Trump’s attacks on the city racist, Klacik defended them — and her video — saying the episode brought necessary attention to the conditions in the city.

“I understand this is quite a battle and quite a challenge,” said Klacik, 38, a self-described college dropout who competed in beauty pageants and set up a nonprofit organization to help disadvantaged women. “But I’m up for it. I’m in the city every single day, and I feel like a lot of people are like, ‘Wow, do you think we can have more than the status quo?’ ”

In addition to Matory and Klacik, the Republican field includes Christopher M. Anderson; James C. Arnold; Ray Bly; Brian L. Brown; Reba A. Hawkins; and William Newton.

Cummings’s death left open a seat he had held since 1996. Twenty-three Democrats are running to replace him, including his widow, Maya Rockeymoore Cummings, and Kweisi Mfume, who previously represented the district in Congress before stepping aside to head the NAACP.

Republicans and Democrats will select their nominees in a Feb. 4 primary. The winners will face off in an April 28 general election that coincides with the primary contests for the November election for a full two-year term.

Republican Party veterans acknowledge that the district, which winds across Baltimore County’s suburbs to the north and west, encircles a chunk of Howard County and juts through West Baltimore into the inner city, does not hold much promise for them. Eighty-one percent of the district’s voters are Democrats.

Joe Cluster, former executive director of the state Republican Party, called it “the most unwinnable district for Republicans in Maryland.” (Dirk Haire, the state GOP chairman, did not respond to calls and messages seeking comment.)

More than 52 percent of the approximately 716,000 people who live in the district are African American. About 5 percent are Latino; around 12 percent are foreign born. The median income is $60,729, and the income of more than 10 percent of the population falls below the poverty line. Half of the district’s 422,432 eligible voters live in the city.

Douglass Mayer, a Republican strategist who previously served as communications director for Gov. Larry Hogan (R), said the district’s electoral outcome was all but preordained when Democrats redrew the boundaries in 2011.

“This district is hard for Republicans to run in exactly because that’s the way it’s designed,” Mayer said.

So why bother? Why should Republicans, or any party, put forward candidates in an unwinnable district?

Notwithstanding the occasional miracle, political parties run candidates against extra-long odds for any number of reasons. It forces opponents to commit at least nominal resources there that might otherwise flow to a more competitive race. In the long term, there is also the chance that circumstances and changing dynamics might someday make the district competitive again.

“This isn’t about winning or losing. This is about the ideas of the party,” Cluster said. “We should run for every seat.”

The calculus is more difficult — and more personal — for the actual candidates, who must rise early to shake hands with commuters and pass out fliers at a local grocery store, or spend their weekends fundraising and knocking on doors.

Even a minimal effort requires filing paperwork, launching a website and showing up at candidate forums — and risking ridicule from friends and colleagues wondering why anyone would spend time this way.

“I’d say they ought to do a lot of soul-searching,” Mayer said.

The right candidate is someone who is a true believer in the party’s ideals, can spread that message effectively, deals with rejection well and loves a challenge, Mayer said. The wrong candidate is someone whose views are so out of step with his or her neighbors — say, an ultraconservative in the 7th Congressional District’s case — that there is little chance of making any impact. Even worse is the candidate who runs to build a private brand, whether for an existing business or a crack at a job as a talking head on cable television.

“Only do this if you have a burning desire,” Mayer said.

Hawkins, who lost a race for Baltimore City Council in 2007, said she knows what it is like to run an uphill race. But she said she also senses that people are eager for new candidates and fresh approaches to problems such as poverty and crime.

“Believe it or not, even though I’m a Republican candidate, I’ve been getting a lot of positive feedback from the masses in the community,” Hawkins said. “And as I tell them, we’ve had good and bad from both parties. But right now you need to vote for the best person that has your true interests in mind, and that person is myself.

“I’m living in the district. I’m experiencing the same ills as everyone else. When I turn the TV on, I’m hoping it’s not my sons being rushed to the hospital.”

At a candidate forum in Elkridge, the six participants — Anderson, Arnold, Bly, Hawkins, Klacik and Matory — were united in giving Trump generally high marks, opposing abortion, praising free markets and accusing Democrats of locking up the vote in the district while ignoring its problems.

At least 60 people attended, including Denise Lee, a Democrat and Trump supporter who works in the Howard County Public School System.

“I was very pleased,” said Lee, 52. “I actually liked all the candidates.”

Lee said it was important for Republicans to offer voters another option despite the odds against them.

“You can’t just say it’s a done deal,” she said.