Controllable optical properties are important for optoelectronic applications. Recently, the two-dimensional MoSi2N4 monolayer was successfully synthesized by chemical vapor deposition, showing remarkable stability in the ambient condition. Motivated by this achievement, herein, we investigate the electronic and optical properties of MoSi2N4 monolayer under mechanical strain through the first-principle calculations. The considered monolayer is structurally and dynamically stable. It is a semiconductor with an indirect band gap of 1.92 eV so that the size of the band gap is easily tuned under biaxial strain. By increasing the tensile strain up to 6%, the effective mass of holes increases to 3.84 me whereas the effective mass of electrons reduces to 0.43 me. In other words, under the strain of 6%, one can have strongly localized holes together with free electrons simultaneously in MoSi2N4 monolayer, which could bring fascinating features like ferromagnetism and superconductivity. Under the strain from 10% to 18%, a Mexican hat dispersion is observed in the highest valence band in such a manner that its coefficient increases from 0.28 to 2.89 eVÅ, indicating the potential thermoelectric application of MoSi2N4 monolayer under strain. Under the strain of 8%, the light absorption coefficient is improved by almost 70%. More importantly, this monolayer tolerates biaxial strain up to 18% and stays mechanically and dynamically stable, making it very promising for flexible nanoelectronics. The controllable electronic and optical properties of MoSi2N4 monolayer may open up an important path for exploring next-generation optoelectronic applications.