The skin acts as a physical barrier, preventing the entry of harmful substances and microorganisms into the body. It also contains immune cells that help defend against infections and play a role in wound healing.