Interesting question. Regarding your observation about the greater prevalence of concerns with homophobia in detective fiction vs other fiction genres, that seems like a bit of a stretch conclusion...maybe even premature. In other words, more cross-genre evidence is required in support of the claim.
What's worth noting (as you've done) is that there has been a slow diffusion or evolution in US culture with dominant or majority attitudes towards homosexuality from 'the love that dare not speak its name' to its tolerance and acceptance in some segments of society. It may seem hard to understand today but when Chandler and Hammett were writing (the 30s) cultural prohibitions were such that it would have been considered avant garde just to broach the topic. One 'safe' way of doing this was to mention it while simultaneously expressing disgust or hatred for the preference. Tracking these attitudes back to 19th c England and Sherlock Holmes is more complicated but one good index of their times is the case of Oscar Wilde, the gay writer, playwright and Victorian contemporary of Conan Doyle, and his imprisonment for 'gross indecency with men' (https://en.wikipedia.org/wiki/Oscar_Wilde).
The thing to bear in mind is that such shifts in cultural attitudes are like pendulum swings. There may be tolerance with LBGT issues in the 'dominant' US culture today but that can change pretty quickly with a reimposition of repressive attitudes and hatred.