What is the technical reason for repeats to not be automatically "played"
(i.e. unfolded) as many times as necessary in the MIDI output?
The "\unfoldRepeats" is a crude hack, and I fail to see the justification
behind this feature. Surely, lilypond knows how to iterate over repeats
to be able to process "\unfoldRepeats" so surely it should not have any
problem generating correct MIDI output without this directive.
Why isn't this behaviour "fixed" to behave normally, i.e have MIDI output
reflect the music as written?

Currently, MIDI is mainly intended mainly for prooflistening purposes, and
it's not very relevant to listen to repeats when prooflistening.

There are also technical reasons: The interpretation of "volta", "unfold" etc.
is not done by the midi/layout backends, but by music iterators. And music
iterators don't know whether midi or layout output is being produced.

I'm planning to restructure the syntax of \score, \book and \midi in the
2.9 cycle so this will no longer be an issue.