Multilayer multiconfiguration time-dependent Hartree (ML-MCTDH) theory is a rigorous and powerful method to simulate quantum dynamics in complex many-body systems. This approach extends the original MCTDH theory of Meyer, Manthe, and Cederbaum to include dynamically contracted layers in a recursive way, within which the equations of motion are determined from the Dirac-Frenkel variational principle. This paper presents the general derivation of the theory and analyzes the important features that make the ML-MCTDH method numerically efficient. Furthermore, we discuss the generalization of the theory to treat many-body identical particles (fermions or bosons) as well as calculating energy eigenstates via the improved relaxation method.