Where does "funk" and/or "funky" come from and why the musical reference?
Solution 1:
As the Wikipedia entry on Funk indicates, Yale art historian Robert Farris Thompson has posited an African origin to the musical use of funky. Here is an expanded quote from his 1984 work, Flash of the Spirit: African and Afro-American Art and Philosophy:
The slang term 'funky' in black communities originally referred to strong body odor, and not to 'funk,' meaning fear or panic. The black nuance seems to derive from the Ki-Kongo lu-fuki, 'bad body odor,' and is perhaps reinforced by contact with fumet, 'aroma of food and wine,' in French Louisiana. But the Ki-Kongo word is closer to the jazz word 'funky' in form and meaning, as both jazzmen and Bakongo use 'funky' and lu-fuki to praise persons for the integrity of their art, for having 'worked out' to achieve their aims. In Kongo today it is possible to hear an elder lauded in this way: 'like, there is a really funky person!--my soul advances toward him to receive his blessing (yati, nkwa lu-fuki! Ve miela miami ikwenda baki) Fu-Kiau Bunseki, a leading native authority on Kongo culture, explains: 'Someone who is very old, I go sit with him, in order to feel his lu-fuki, meaning, I would like to be blessed by him.' For in Kongo the smell of a hardworking elder carries luck. This Kongo sign of exertion is identified with the positive energy of a person. Hence, 'funk' in black American jazz parlance can mean earthiness, a return to fundamentals.
Solution 2:
Funk is actually quite interesting, because it is a back formation from funky, which in turn was formed from funk. As in, funk didn't just go from "bad smell" to "music genre" all by itself; it took a detour via the adjective form. Confusing, huh? Etymonline explains it thus:
funky "old, musty," in reference to cheeses, then "repulsive," from funk ["bad smell," 1620s, from dialectal Fr. funkière "smoke"]. It began to develop an approving sense in jazz slang c.1900, probably on the notion of "earthy, strong, deeply felt." Funky also was used early 20c. by white writers in reference to body odor allegedly peculiar to blacks. The word reached wider popularity c.1954 [...] and in the 1960s acquired a broad slang sense of "fine, stylish, excellent."
Solution 3:
funky originally meant pungent / earthy, with relatively positive associations to "passive" qualities such as the smell of a cheese, which just sits there mouldering away. Since being co-opted into jazz slang it's acquired the more "active" overtones of actual movement in the sense of lively, rootsy, etc. (funky music encourages dancing & foot-tapping).