The role of the microshutters is NOT to act as pinholes or coded aperture and to produce a focused image, similar to a mirror or lens.
Its job is just to separate the the light from different sources. This is achieved simply by opening only the shutters corresponding to the sources of interest. See the following image:
This is important for spectroscopy as here the light is split in its wavelengths and dispersed in one direction by a grating or prism. That is why Webb's micro-shutter is only used for spectroscopy. In order to not have a bunch of overlapping spectra you need some shutters to block everything you are not interested in. The spread out image of multiple sources on the detector than looks like this:
In other words: As you can not detect a 3D image3D image (2 spacial + 1 spectral) on a 2D detector, you have to make some sacrifice by blocking much of your field of view.
This sketch makes the process quite clear:
Further sources: Wikipedia Closed-source micro-shutter decription