Key of A minor:
Am - Em/G - F - D - Dm - Am/C - B - E
How would you describe the D chord?
I'm not sure. Is it from a melodic minor?
Is there any specific reason why this progression works well?
The simplest answer is that chords are borrowed from the parallel key quite often. This is in key A minor, and all the other chords are diatonic to it and its various scale notes. So, yes, it could easily be seen to come from A melodic minor. That will explain the E major chord as well. But it's just as easily seen to come from the parallel key - of A major - it being IV in that key.
None of this explains the B chord, also non-diatonic. But since it's V/V - the dominant chord of the dominant chord - it leads nicely to the E major, dominant of A (maj or min), then probably returns to Am.
D in the key of A minor is a fairly common sound, and there are a couple ways to view it.
For starters, let's get this out of the way first: D major is not in the key of A minor, as you've noticed. D major is, however, diatonic to A dorian. As you've noticed, it's also diatonic to A melodic minor. In the specific case you've outlined, it sounds like it's definitely a borrowed chord. If I had to pick one, I'd say it's borrowed from A Dorian, because generally I don't like to say "borrowed from melodic minor" unless most of the progression is also melodic minor, but it wouldn't be wrong to say that. A more general term for this kind of chord is modal mixture.
Now, just because that one chord is from dorian/melodic minor doesn't mean the rest of the progression has to be the same. Obviously, the tonic here is some sort of A minor, and the rest of the chords make sense in A minor as well.
If you're curious, the reason I say that the B makes sense is because it's a secondary dominant. E is the dominant of A minor, and the dominant of E is B, so B major, though non-diatonic, functions in the key of A minor with predominant function.
A lot can depend on the rhythm and voice leading, but if we skip that for the moment, you could abstract your progression to...
Am... Dm and
First it goes to the subdominant and then it goes to the dominant. Tonally that is very clear harmony. If you are somehow emphasizing
E as targets, it should make the tonality even more emphatically clear.
Am Em/G Dm/F E and
Am G7 F7 E7 are common progressions. From that perspective you might be able to abstract the progression to...
Am - Em/G - F... E
It's a mix of the two progressions at the point of
F, whether the chord is root position or inverted, but the descending bass at the opening seems clear. Instead of simply going to
E you elaborate with another descent
D C B before getting to the dominant
Apologies for a messy answer, but even though the question is short, the answer needs a lot of stuff. :) I suspect you're not only interested in the D chord, but what happens in the progression.
Why the chord progression works: it utilizes different harmonic movements, tension and release, old and new, familiar and unfamiliar. Keep something, change something. Do something expected, do something unexpected. You need to know a few different elements and dimensions of harmony to see why something might feel like expected and why something might feel unexpected. These dimensions are how you keep track of what changes or stays the same, and how you create expectations, tension and release.
One very basic thing is the scale. It's more expected that the scale stays the same than that it changes. Another basic thing to look for is the I / IV / V axis. The harmony is either at rest (or "at home") at I i.s. tonic, or leaning on the IV i.e. subdominant side, or the V i.e. dominant side. In the key of C major / A minor these are: tonic:C/Am, subdominant:F/Dm, dominant:G/E (or Em). The movement from G (or G7) to C, or from E (or E7) to Am is a dominant-tonic motion. When you're at a dominant chord, e.g. E7, the least unusual thing to happen next is to get the tonic Am. Then you have the overall sense of where tonic is i.e. where "home" is. Not being home is, in a way, tension. How far away are you from home? If home moves, basically everything changes, you have to find a new orientation for everything.
(Side-note: The only root note that's left from the set of six chords Am, C, Dm, F, E, G is B. What's that? Dm6/B can be thought of being e.g. a mixture of a Am's subdominant Dm and "secondary dominant" B, which is E's dominant.)
You could say that the D major chord in the chord progression "borrows" from the parallel major key (A major), or that it brings feeling from the Dorian mode for a brief moment. Moving between minor/major can be thought of being a bit unexpected. You're settled at e.g. A minor and expecting the scale etc. but then you get an F# note which you're used to hearing in other keys, so have to do a bit of re-thinking. Something is changed, something stays the same.
To make the change last longer than just the D chord, it could go like this: Am - Em/G - F - D - A/C# - B - E. Can you hear the difference?
Another thing you have there is voice leading, stepping a voice or two up or down. The bass goes down: A - G - F - D - C - B - E. The final step can be seen as a V-I jump, although not from Am's V but E's V. Stepping a voice up or down by one step is perhaps in the conventional or expected side of things. But the conventionality feels safe and lets you do unexpected changes in other dimensions, to balance the expected and unexpected.
(You could say something about the movement of other voices move as well, but the lowest note is an easy pick because there's only one lowest note. For the other voices it could be argued if the motion was up or down, and the chord symbols don't really dictate exactly how the notes should be spread in different octaves)
If we map the chords to the tonic/subdominant/dominant role world, it goes like this:
- Am : tonic
- Em/G : dominant (but not the strongest one E7)
- F : subdominant
- D : subdominant (but different)
- Dm : subdominant (but different)
- Am/C : tonic
- B : "secondary" dominant (giving a brief feeling of E being the tonic)
- E : dominant
In the above I consider Am and C both being "tonic", which is in a way unorthodox. ;) But in most cases you can replace any chord with the relative minor/major while keeping most aspects of its function.
The final E leaves a strong expectation for an Am, which nicely wraps the chord progression and makes you want more of the same.
Changing between tonic and subdominant sides isn't necessarily very unexpected, but it is a change, which gives the progression some character.
So... that's why it works. Try it yourself, take something as a starting point, and then step by step change something in one of the dimensions.
One last thing to add: chords or chord symbols are not a physical or biological thing in your head, and there's no single correct dimension for reasoning about what happens in harmony. Chords are ready-made product packages, macro building blocks developed for practical use in Western music culture. Harmony construction kit for dummies. Even if you can select between a kitchen block, bedroom block and a toilet block, it doesn't mean that you can't combine the functions of those blocks in countless variations. :)
You could justify it as from the melodic minor if you wanted to. But always remember, the scale is a framework, not a restriction (I seem to be typing that phrase a lot lately!) You don't need an excuse to use an out-of-scale note. Free mixing of the major and minor chords on the subdominant is very common in both major and minor keys.