The function of the soap is to help wash off the oils. Because oil is hydrophobic, and soap is made of molecules that are both hydrophobic and hydrophilic, the soap molecules can connect to both oil and water. When the soap is combined with water and oil, it causes the oil to form small drops that can easily be washed off.
I hope I could help!