Diffraction happens because the electromagnetic fields must satisfy the wave equation.
The electromagnetic field is attenuated by the material of the slit, therefore the electromagnetic field cannot be represented as a perfect plane wave when it goes through the slit. (A perfect plane wave requires a large amount of free space).
If the slit width is much larger than the light's wavelength, the amplitude of the field drops off after many wavelengths to the side, so in the middle of the slit, the wave is mostly planar. (I.e. diffraction doesn't happen much).
If the slit is comparable to the wavelength, the wave cannot be planar within the slit, because the amplitude must drop off only a wavelength to the side, so the planar quality of the wave is messed up.
So basically, it is because of constricting boundary conditions that the wave inside the slit can't be planar (if the slit size is comparable to the wavelength), which causes diffraction.