First-principles calculations were used to study the energetics and electronic structures of Ni and Sc co-doped MgH2 system. The preferential positions for dopants were determined by the minimal total electronic energy. The results of formation enthalpy indicate that Ni and Sc co-doped MgH2 system is more stable than Ni single-doped system. The hydrogen desorption enthalpies of these two hydrides are investigated. Ni and Sc co-doping can improve the dehydrogenation properties of MgH2. The lowest hydrogen desorption enthalpy of 0.30 eV appears in co-doped system, which is significantly lower than that of Ni doping. The electronic structure analysis illustrates that the hybridization of dopants with Mg and H atom together weakens the Mg-H interaction. And the Mg-H bonds are more susceptible to dissociate by Ni and Sc co-doping because of the reduced magnitude of Mg-H hybridization peaks. These behaviors effectively improve the dehydrogenation properties of Ni and Sc co-doped cases.