Due to surface tension, the free surface of liquid at rest behaves like a stretched membrane. When an iron needle floats on the surface of deem water, its weight is supported by the stretched membrane. When some detergent is added to this water, its surface tension decreases.
As a result of it, the stretched membrane on the surface of water is weakened and is not able to support the weight of needle. Hence, needle sinks in such water.