Soap is a chemical with a long, and kind of clever, molecule. One end of the molecule attracts water. The other end attracts dirt, particularly oily dirt. So when you wash stuff, the oily-liking end sticks in the oily dirt and the other end gets stuck in water… and so the oily dirt gets pulled away from what you are cleaning when the water-liking end gets pulled away through scrubbing or swirling water around. So put some soap on your greasy hands, and scrub a bit, and all the greasy stuff gets lifted away.
Now there are different levels of soap out there. The CLEANING 100 soap doesn’t care about gentle, it just sucks dirt up like crazy at the expense of wimpy stuff like moisture and balance. The weaker soap works, but not quite so well, but at least it doesn’t damage your skin or eyes, or dry out stuff in the process.
So stronger soap chemicals are great for super greasy dirt, but the trade-off is they cause your eyes to sting when it hits them because your eyes are sensitive to super-effective soaps.
But other soap chemicals don’t cause your eyes to sting because they’re not QUITE so good at sticking to oily dirt at one end, so they’re not quite so good at cleaning or wrecking the careful balance of chemistry that keeps your eyes moist and in good shape.
So we have a trade-off: oily dirt removal? Or no irritation to the eyes? Which one you want goes to which “soap” you use in your shampoo. And baby shampoo uses the second one even if it doesn’t clean as good as the first, because babies generally don’t stand underneath leaky car oilpans or go swimming in cold deep fryers unless you’re a really bad parent.