The function of terminal deoxynucleotidyl transferase in 5′ RACE is:
Rapid amplification of complementary DNA ends targeting the 5 prime terminus requires generation of a full-length first-strand copy of messenger RNA. After reverse transcription, the complementary DNA possesses an accessible 3 prime hydroxyl at the end corresponding to the messenger RNA 5 prime region. Terminal deoxynucleotidyl transferase, a template-independent polymerase, adds a homopolymeric tract, typically poly-adenine or poly-cytosine, to this 3 prime end. This artificial tail provides an anchor site for an oligo-dT adapter primer, enabling subsequent PCR amplification using gene-specific and adapter primers to capture unknown upstream sequences.
Ref: NCERT Biology Class XII Principles on Klenow fill-in labeling, Lehninger Chapter 9 DNA cloning techniques, and Molecular Cloning by Sambrook Chapter 10 documenting end-labeling of cohesive termini.