The effect of elemental doping on the site preference, elastic properties and electronic structure of Mg17Al12 has been systematically investigated by first-principles calculations. And twenty-seven elements (Li, Na, K, Ca, Sc, Ti, V, Cr, Mn, Fe, Co, Ni, Cu, Zn, Ga, Ge, Sr, Y, Zr, Ag, Cd, In, Sn, Sb, Pb, Bi and La) are considered in this study. The calculations of substitution formation energies indicate that the alkali metal (Li), alkaline earth (Ca, Sr) and rare earth (Sc, Y, La) group elements and Ti, Zr favor to occupy Mg sites, and transition group (Fe, Co, Ni, Cu, Ag, Zn, Cd) elements and Ga, Ge, Sn, Sb prefer to occupy Al site, while Na, K, V, Cr, Mn, In, Pb and Bi are unstable in Mg17Al12 phase. Meanwhile, the results of phonon dispersion curves for the preferentially doped systems show that all doped structures are dynamically stable except for Sr, La and Sn doped systems. The elastic constants indicate that all preferential doping models are mechanically stable, and solute atoms with high bulk modulus lead to an increase in the bulk modulus of Mg17Al12 phase. Simultaneously, the calculated shear modulus/bulk modulus ratio (G/B), Poisson's ratio (v) and Cauchy's pressure (C‾12‐C‾44) indicate that the ductility of doped systems is better than Mg17Al12 alloy. All structures are elastic anisotropic, while the doping of Fe, Co and Ni reduces the degree of anisotropy of Mg17Al12 phase. Furthermore, the electronic structures show a strong hybridization between the p-orbitals of Mg and Al and the d-orbitals of alkaline earth, rare earth and Zr elements, resulting in higher structural stability. Finally, the adsorption behavior of O atom on Mg17Al12(110) surface and the structural stability, lattice constants, and elastic modulus of Mg34Al24-xZnx random solid solution alloys are investigated.