Scanning tunneling microscopy and spectroscopy and X-ray photoelectron spectroscopy (XPS) have been used to investigate the differences between the surface electronic structures and chemical structure of typically prepared and N-doped Nb cutouts from superconducting radio frequency (SRF) cavities. The goal of this work is to get insights into the fundamental physics and materials mechanisms behind the striking decrease of the surface resistance with the radiofrequency magnetic field, which has been observed by many groups on N-doped Nb cavities. In particular, we address the effects of N-doping on the superconducting properties at the surface of SRF cavities. XPS measurements reveal a significantly more oxidized Nb 3d states on the N-doped Nb surfaces which is confirmed by tunneling spectroscopy measurements. Analysis of the tunneling spectra in the framework of a recent model (A. Gurevich and T. Kubo Phys. Rev. B 96, 184515 ( 2017)) shows that the N-doping greatly reduces local distribution of superconducting properties on the surface, causes a significant shrinkage of the metallic suboxide and changes the contact resistance between the metallic suboxide and the bulk niobium toward an optimum value, resulting in a lower surface resistance. Combination of these factors enables one to effectively tune the density of states at the surface and to reveal the decrease of the surface resistance with the radio frequency field which follows from the BCS theory. A slightly reduced average gap and a smaller coherence length, revealed by tunneling spectroscopy in the vortex cores, have been found in the N-doped Nb samples compared to typically prepared Nb samples, indicating a stronger impurity scattering caused by nitrogen doping in a moderately disordered material.