A needle was a tool that was used to weave fabric together to create garments. Needles were also used for various medical purposes such as injecting drugs before hyposprays and taking blood, and along with suture material, to bind together body tissue after an operation or injury.
The idiom "needle in a haystack" refers to something being difficult to find or do. Miles O'Brien would occasionally use the term, as did Jadzia Dax once. (TOS: "The Galileo Seven"; TNG: "The Naked Now"; DS9: "Battle Lines", "Whispers", "Blaze of Glory")
While in the year 1930, the delusional Doctor McCoy rambled on about the inadequacies of 20th century medicine, stating, "they used to hand-cut and sew people like garments. Needles and sutures, all the terrible pain!" (TOS: "The City on the Edge of Forever")