Density functional theory and exchange-correlation approximation are used to determine structural electronic and optical characteristics of Al1-xMgxSb (x =0, 0.25, 0.5, 0.75). We employ generalized gradient approximation (GGA-PBE) to calculate structural properties as lattice parameters, bulk moduli, and pressure derivatives are in good agreement with the experimental data. The GGA-PBE algorithm determines the density of states and band structure for electronic characteristics. These calculations show the optical inactivity and indirect (Γ-L) bandgap of the binary compound AlSb. When a variable percentage in AlSb raises Mg concentration, the bandgap decreases and switches from indirect bandgap (Γ-L) to direct bandgap) and the material starts to function optically. The optical properties of Mg-doped AlSb as reflectivity, optical conductivity, reflectivity, refractive index, dielectric constant and energy loss are significantly improved. The designated material is considered a gateway for optoelectronic and photonic applications.