We use metaphors when we take a word or a phrase to refer to something else, whether by symbolizing it or suggesting that is similar to another thing, person, idea, quality. Thus, they can not be taken literally.
The sentence "If hairs be wires, black wires grow on her head." uses this figurative language by comparing "hairs" to "wires", perhaps because of their physical appearance.
One way to use slang and idioms in a story is to make characters feel more natural and funny. Unless a character is very formal, real people would not talk without slang or idioms.