The purpose of the slit is to prevent overlap of different spectral components at the screen or detector.
Imagine what happens if the light contains just one spectral component and there is no slit: there would be a spot of light on the screen, as wide as the face of the prism. Now add another spectral component with a slightly different wavelength, and there would be two wide stripes, overlapping. It would not be possible to distinguish the two wavelengths by examining the light distribution on the screen. When a slit is included, the stripes corresponding to the spectral components are narrowed in proportion to the slit width, so if the slit is sufficiently narrow it is possible to see two stripes, each corresponding to one of the wavelenghs.
The minimum wavelength difference a spectrometer like this can distinguish is proportional to the slit width.