The primary function of the granular layer is to form a barrier to prevent water loss from the body. The keratohyalin granules play a crucial role in the aggregation of keratin filaments, which leads to the formation of a tough, protective layer. Additionally, this layer is involved in the process of keratinization, where cells undergo a series of changes to become part of the stratum corneum.