In the famous book 'Residues and duality', the author notes that one of the principal difficulties in constructing the exceptional inverse image functor $f^{!}$ is that the derived category of quasicoherent sheaves is not a local object. In order to resolve this difficulty, the author first defines it for residual complexes, a procedure he finds 'clumsy' and 'roundabout'.
In his notes on Geometric Langlands, D. Gaitsgory forcefully explains the necessity of considering DG enhancements to define the derived category for general prestacks
The problem is that the gluing procedure alluded to above, is not defined for triangulated categories. (This was the problem that Hartshorne had to confront in his “Residues and duality”; this is why that book is so thick, instead of being just 10 pages long.) Now, the advatnage of the ∞-category language is that gluing can be defined for DG-categories.
Is there a high-level explanation as for why the difficulties occuring while trying to glue derived categories (as triangulated categories) are resolved if we pass to DG categories? In other words, how could someone trying to solve this problem come up with the idea to introduce DG enhancements?