The primary function of lysozymes is to degrade the peptidoglycan layer of bacterial cell walls. This enzymatic activity leads to the lysis of bacteria, effectively killing them. By doing so, lysozymes help to prevent infections and contribute to the immune response. Their action is particularly effective against Gram-positive bacteria, which have a thicker peptidoglycan layer compared to Gram-negative bacteria.