Substrate, environment, and lattice imperfections have a strong impact on the local electronic structure and the optical properties of atomically thin transition metal dichalcogenides. We find by a comparative study of MoS2 on SiO2 and hexagonal boron nitride (hBN) using scanning tunneling spectroscopy (STS) measurements that the apparent bandgap of MoS2 on SiO2 is significantly reduced compared to MoS2 on hBN. The bandgap energies as well as the exciton binding energies determined from all-optical measurements are very similar for MoS2 on SiO2 and hBN. This discrepancy is found to be caused by a substantial amount of band tail states near the conduction band edge of MoS2 supported by SiO2. The presence of those states impacts the local density of states in STS measurements and can be linked to a broad red-shifted photoluminescence peak and a higher charge carrier density that are all strongly diminished or even absent using high quality hBN substrates. By taking into account the substrate effects, we obtain a quasiparticle gap that is in excellent agreement with optical absorbance spectra and we deduce an exciton binding energy of about 0.53 eV on SiO2 and 0.44 eV on hBN.