From Proto-Indo-European *deyǵ- (“to show, point out, pronounce solemnly”), variant of the root *deyḱ- that also gave Latin dīcō (“I say, speak talk”) and English toe. Fingers were thus "pointers, indicators". Digit sense comes from the fact that they were used for counting up to ten.
Indo-European cognates include Sanskrit दिशति (diśáti, “to show, point out”), Ancient Greek δείκνυμι (deiknumi, “to show”), δίκη (dikē, “manner, custom”), Old English tǣċan (“to show, point out”) (English teach) and tācen (English token).
Compare similar semantic shift in English in the cognate word teacher (“forefinger, index finger”).