Looking at Wikipedia’s page on the 2016 election, I see that Clinton got 90.48% of DC’s vote; Trump only got 4.07%. This is by far the most any candidate got in any state; behind it is it Nebraska’s 3rd congressional district with 73.92% for Trump. Why is D.C. so Democratic?
Because it's just one (East Coast) city.
When it comes to congressional districts, Nebraska's third congressional district isn't second in terms of the ratio of votes for a single candidate. DC isn't even first. Several districts in New York, for instance, went overwhelmingly for Clinton. She got a full 92% in the 13th district and 94% in the 15th.
When we look at this, it's clear what's going on. Washington D.C. can't really be compared with any state. It's quite small, and due to its size is much more urban than any of the 50 states. In essence, it's a city. Its surface area is 68 square miles, only three times that of Manhattan. This is important, because Republicans have more support in rural areas, and Democrats have more support in urban areas. Congressional districts are often drawn to include both rural and urban areas, which means that these tendencies balance out a bit. But if your district is one city, it's likely to be more Democratic. And of course, most cities on the East Coast of the United States lean Democratic. So in essence, DC's voting pattern isn't unusual if we compare it to the proper metric, districts in other East Coast cities.
As to why cities tend to be liberal, it's a combination of socioeconomic, cultural, and racial and ethnic factors, as outlined here. The occupations that most benefit from liberal policies, such as high social safety net spending, are concentrated in urban areas; those that most benefit from conservative policies are concentrated in rural areas. White voters are more likely to be conservative, and are concentrated in rural areas; African-American and Latino voters, as well as immigrants are more likely to be liberal and are concentrated in urban areas; moreover, exposure to people from different groups is correlated with greater acceptance of those groups, so even white voters in ethnically diverse cities are likely to be more supportive of liberal policies in that regard. College-educated voters are more likely to be liberal, and they are concentrated in urban areas. And so forth.
42@Stormblessed - OK. But that doesn't change the answer. Quite simply, DC is a city, and a small one. It's going to vote like a left-leaning, ethnically diverse East Coast city, not like a state with a mix of liberal cities and conservative, religious, primarily white rural areas.– Obie 2.0Jul 22, 2019 at 3:51
4How long has the urban/rural Democrat/Republican correlation been true? If there was a time when it was not true (i.e., a time when DC was mostly Democrat but party affiliation was more homogeneous across urban and rural districts), that would tend to undercut this answer - but I don't have time to look into it! Jul 22, 2019 at 19:15
7@TupeloThistlehead: Short version: White flight made cities blacker (and removed the most conservative/racist white voters). The Civil Rights Act was largely credited to LBJ (so black folks were favorably inclined towards Democrats), while Nixon's (and subsequent GOP contenders) Southern strategy further alienated black voters. Put it all together, and many cities became heavily Democratic due to outsize margins in the black vote alone. Jul 22, 2019 at 22:09
6There is more to it than that (white voters in cities tend to be more liberal than rural white voters), but that's a big component of it. Jul 22, 2019 at 22:09
6@ShadowRanger You might equally argue that Democrats are less likely to turn up and vote in D.C. because the Democrats will win anyway. See also the question In first-past-the-post/winner-takes-all elections, is turnout higher in marginal seats / swing states? — and if you have any evidence for your turnout speculation, please do post it there. Jul 23, 2019 at 8:16
DC is highly urban (I'm not using this as a dogwhistle for black people by the way, though they are a large portion of DC residents). It's the only quanta of electoral votes that's not only a city, but a city with its surrounding metro area (suburbs and exurbs) pared away since they're part of MD or VA.
For example, compare the DC numbers of 90.48% for Clinton with this electoral map of Chicago, which shows 83.7% for Clinton, also higher than the 73.92% voting for Trump in Nebraska. Chicago also has over 3 times the surface area of DC, if you were to somehow to superimpose a rough DC sized square over downtown, you'll notice that you'll end up with more of the darker blue areas as opposed to the lighter blue areas (when compared to the entire map), raising Clinton's numbers even higher.
1It's probably worth noting that Nebraska 3 contains only two cities with more than 30,000 people (Grand Island has about 49,000 and Kearney has about 31,000); there are another five with 20-30k people and everything else is under 15k. Jul 22, 2019 at 12:22
4@DavidRicherby Indeed, it's been said that if the University of Nebraska's Memorial Stadium were considered a separate city, and the census were taken during a home game, it would be the third-largest city in the state. It holds nearly as many people as Bellevue and Grand Island combined. Jul 22, 2019 at 17:05
Washington, D.C., as you may know, is the home of the federal government. Many of the people there work for the federal government, and many others depend on the federal government for their livelihood. Even if they run a restaurant or a laundry, they probably depend on federal government employees for their income.
Republican candidates in recent decades have often run on a platform of making huge cuts to the federal government, sometimes even of disrupting the federal government, and often deliberately adopt an attitude of confrontation to federal government and its employees. Whatever their other motivations, federal employees know that an attitude of confrontation, cuts and disruption is going to make their jobs harder and probably less well paid. For Trump specifically it was no secret that having a president with no experience of government at any level was going to make the jobs of federal employees harder.
Related to this is the fact that those who want to minimize or abolish big chunks of the federal government (i.e. many Republicans) tend not to get jobs as federal employees, and so not live in D.C.
12This is entirely plausible, but is it true? Is there any evidence that people vote for the Democrat because they believe the Republican threatens their own job, but would otherwise vote Republican from a platform point of view? As Obies answer has pointed out, New York is at least as much democratic leaning as DC. Perhaps sources for answers that are plausible are as important as sources for answers that are surprising. Jul 23, 2019 at 8:19
9@Shadur That's another great theory, which would be even greater if it was true, but which unfortunately does not match with the observation that plenty of Trumps fans appear to still like him knowing exactly what he is like. Jul 23, 2019 at 11:09
3I spent 5 years in the region and this doesn't ring true to me at all. The number of federal workers is not big enough to have this effect and many live outside the district. Jul 23, 2019 at 15:37
2@gerrit: There really isn't a shred of evidence to support this theory, and it is thoroughly undercut by the fact that other cities exhibit very similar voting patterns regardless of their dependence on the federal government. Jul 23, 2019 at 17:10
Great answer. The answers above about cities voting Democratic are certainly true but I knew if I scrolled down I’d find an interesting take on it. Maybe this answer doesn’t account for a huge percentage of the Democratic vote but even a few percentage points would make DC more extreme than most other places.– jonstiegJul 24, 2019 at 17:29
Demographics: Because it is so, so, so African-American and Hispanic. DC is what we call a majority-minority area.
As of last census, DC reported as 50.7% black (and 9.1% Hispanic). This is actually a big decrease from past decades, where it was actually over 70% black in the 1970's (but less Hispanic as well).
African Americans nationwide identify as about 85% Democratic (and Hispanics about 60%). This percentage has been slowly increasing (offsetting some of the demographic losses). If you do a bit of napikin math, plugging in the national racial party ID numbers to DC's demographic breakdown, you'd expect to see about 64% of DC voters to at least lean Democratic. This is before we account for the fact that white Republicans tend to like to self-sort themselves out of urban areas like DC into more Republican-leaning areas. In the DC metro area, those suburban areas are all in the jurisdiction of Virginia or Maryland, not in DC.
As other answers mentioned, this isn't horribly unusual for a major city in the US's Northeast Corridor. However, with other cities politicians are usually able to blunt this advantage a bit by grouping them with some voters from more rural outlying areas that are heavily white. DC has been carved out as a unit by itself, so the urban area is pretty much all we can get (unless Maryland wants to consider taking it back, like Virginia already took back its half). What you see with deep Republican unpopularity in D.C. is what you'd see with most large US cities if it couldn't be hidden.*
* - The contrary also applies of course, in that, as the question points out, Democrats are also unpopular in a lot of uniformly white rural areas.
There are, I believe, a combination of factors that make DC very Democratic. As the other answers state, there is the fact that it is urban, that it is majority minority (i.e. most people in the city fall into a demographic group that is a minority within the whole country - although there are more whites than one might think), and lots of federal government employees who - largely because of hostility that Republicans often exhibit toward them (the employees) - tend to vote Democratic.
There is another reason I want to bring up: Representation of the District at the national level (i.e. in Congress). As you likely know, the Constitution gives DC no representation in Congress. In the last couple decades, Democrats have generally supported giving DC representation in Congress. In fact, since 1993, they have given some voting rights in the full House of Representatives (when operating as a "Committee in the Whole") to DC's Congressional Delegate. On the other hand, whenever Republicans are in control they strip the Delegate of her vote in the full House. It is generally believed that the Democrats would also grant two Senators to the District, but that would require a Constitutional Amendment, which isn't likely to pass anytime soon.
(Source for some of this: https://en.wikipedia.org/wiki/District_of_Columbia%27s_at-large_congressional_district)
Good point. I hadn't even thought of this.– Obie 2.0Jul 25, 2019 at 20:50
1In your second paragraph, though, is that a cause or an effect? Presumably, if DC voters were to trend more Republican, then the Democratic and Republican positions on its representation would reverse.– MeirJul 30, 2019 at 4:13
@Meir: True, it might reverse if DC voters started supporting Republicans instead of Democrats. OTOH, the history is what it is, and I ask: Would you vote for someone who had repeatedly stripped your geographic region of representation? Jul 30, 2019 at 11:03