The primary function of a roof is to protect a building and its occupants from various external elements, including rain, snow, sunlight, wind, and extreme temperatures. By offering this protection, roofs play a crucial role in maintaining the structural integrity and comfort of buildings, adapting in form and material to suit different architectural, economic, and aesthetic needs.