C16 (meaning: fellow): from the name Dick, familiar form of Richard, applied generally (like Jack) to any fellow, lad, etc; hence, C19: penis
The third sense of this word was formerly considered to be taboo and it was labelled as such in previous editions of Collins English Dictionary . However, it has now become acceptable in speech, although some older or more conservative people may object to its use
"fellow, lad, man," 1550s, rhyming nickname for Rick, short for Richard, one of the commonest English names, it has long been a synonym for "fellow," and so most of the slang senses are probably very old, but naturally hard to find in the surviving records. The meaning "penis" is attested from 1891 in Farmer's slang dictionary (possibly British army slang). Meaning "detective" is recorded from 1908, perhaps as a shortened variant of detective.