The primary function of the stratum granulosum is to act as a barrier to protect the underlying tissues from infection, dehydration, and mechanical stress. The keratohyalin granules within the keratinocytes contain proteins such as profilaggrin, which is essential for the aggregation of keratin filaments. This aggregation is crucial for the formation of the skin's barrier. Additionally, this layer helps in the formation of the lipid barrier, which prevents water loss.