Extensive electronic structure calculations, based on the density-functional theory, are used to characterize the equilibrium properties and the behaviour under pressure of MgH2. Moreover, substitutional solid solutions for several 3d metals (Fe, Ni, Ti, Al, Pd, Co, etc.) in MgH2 are characterized by computing both relaxed structures and solution energies. Theoretical results are combined with experimental results on samples synthesized by ball milling. MgH2 was milled with 10 wt.% of 3d metals followed by microstructural characterization and hydrogen desorption behaviour. Good correlation between theoretical solution energies and experimental desorption temperatures reveals a general trend in these systems. A few notable exceptions can be detected, which can be explained in terms of peculiarities in the experimental composite microstructure.