Soap is a surfactant [0], and one of its most useful properties is that it reduces the reluctance of oils and fats to disperse in water, which is why soaps are useful at cleaning your dishes, hair, and skin. Many viruses like coronavirus (so called "enveloped" viruses) are only held together by a thin lipid (fatty) layer, so in the presence of soap and water, they basically just fall apart.
[0] https://en.wikipedia.org/wiki/Surfactant