Found this.The foreskin does actually play a part
The foreskin has numerous protective, sensory, and sexual functions.
Protection: Just as the eyelids protect the eyes, the foreskin protects the glans and keeps its surface soft, moist, and sensitive. It also maintains optimal warmth, pH balance, and cleanliness. The glans itself contains no sebaceous glands-glands that produce the sebum, or oil, that moisturizes our skin.11 The foreskin produces the sebum that maintains proper health of the surface of the glans.
Immunological Defense: The mucous membranes that line all body orifices are the body's first line of immunological defense. Glands in the foreskin produce antibacterial and antiviral proteins such as lysozyme.12 Lysozyme is also found in tears and mother's milk. Specialized epithelial Langerhans cells, an immune system component, abound in the foreskin's outer surface.13 Plasma cells in the foreskin's mucosal lining secrete immunoglobulins, antibodies that defend against infection.14