The primary function of piles is to transfer structural loads to deep, stable strata that cannot be supported by shallow foundations.