If we modify this experiment so that one slit is closed, no interference pattern is observed.
To explain the behavior when the particle is detected to go through one slit, one needs to appreciate the role of the conditional wavefunction and how it results in the collapse of the wavefunction; this is explained below.