Phonon-phonon anharmonic effects have a strong influence on the phonon spectrum; most prominent manifestation of these effects are the softening (shift in frequency) and broadening (change in FWHM) of the phonon modes at finite temperature. Using Raman spectroscopy, we studied the temperature dependence of the FWHM and Raman shift of E$^1_{2g}$ and A$_{1g}$ modes for single-layer and natural bilayer MoS$_2$ over a broad range of temperatures (8 < T < 300 K). Both the Raman shift and FWHM of these modes show linear temperature dependence for T > 100 K , whereas they become independent of temperature for T < 100 K . Using first-principles calculations, we show that three-phonon anharmonic effects intrinsic to the material can account for the observed temperature dependence of the linewidth of both the modes. It also plays an important role in determining the temperature dependence of the frequency of the Raman modes. The observed evolution of the linewidth of the A$_{1g}$ mode suggests that electron-phonon processes are additionally involved. From the analysis of the temperature-dependent Raman spectra of MoS$_2$ on two different substrates - SiO$_2$ and hexagonal boron nitride - we disentangle the contributions of external stress and internal impurities to these phonon-related processes. We find that the renormalization of the phonon mode frequencies on different substrates is governed by strain and intrinsic doping. Our work establishes the role of intrinsic phonon anharmonic effects in deciding the Raman shift in MoS$_2$ irrespective of substrate and layer number.