Sodium Lauryl Sulfate is a surfactant. It helps cosmetic products to remove all the sebum and dirt from your skin. Water can't dissolve sebum on its own because sebum contains oils. Surfactants help water get into sebum and wash off all the unnecessary stuff from your skin.
The component also helps to form a nice foam. The foam allows to spread the product evenly. which is important for good cleansing.
Safety
The component is researched quite well. Studies showed that it doesn't have any negative impact on human health if you apply it to your skin. It can be toxic only if you take SLS inside, but we doubt that somebody likes to drink shampoo or eat soap.
However, the component has its negative side. It can dry out skin or hair too much. You can suffer from this effect if you have dry skin. Plus it can make your hair less protected because natural sebum works like a barrier. Washing it off completely isn't the best idea.