Why the forbidden lines of [OIII],[NII] and [SII],[OII] are sensitive to electron temperature and electron density, respectively?
Forbidden lines like these arise in thin gases, where collisional de-excitation is unlikely. Forbidden lines become "quenched" by collisional de-excitation when the densities reach levels that depend on the detailed quantum physics of each transition (i.e. different for every line/transition).

If you study the ratio of a pair of lines at densities well below their "quenching thresholds", the ratio will depend only on the relative occupation of their upper levels, which in turn depends on the temperature, but is insensitive to density.

If on the other hand you choose a pair of lines with very similar upper energy levels, the ratio will be insensitive to temperature. However, if one transition is around or even above its "quenching threshold", then the ratio becomes very sensitive to density.