Focusing on the cosmological and non-cosmological redshifts existing in the quasars, in this work, we proposed that the different gravitational fields will lead to the changes of the electronic structure of matter. Therefore, the large spectra redshifts in the quasars are well explained based on the changes of the electronic structure of the matter. In the external strong gravitational field, the stable states of atoms (ions or molecules) are different from that of the earth region. The electron "orbital" energy of atoms is decreased in the strong gravitational field, leading to decrease the energy level difference between orbits, and the spectrum shows red shift. Because the orbital energies are proportionally decreased, the atomic spectrum in the strong gravitational field is still to exhibit the characteristic spectrum of the same atom in the earth region, that is, only the whole red shift occurs. We proposed that the different atomic stable states exist due to the different gravitational field intensities, which are discontinuous and gradient. It usually presents as the different quantum states. The quantum states in the earth region are only one of the several quantum states in the universe. Our proposed theory can not only perfectly explain the spectral redshift characteristics and nature of quasars, but also draw the conclusion that the gravitational field changes the matter structure.