The idea of straightness meaning “correct, conventional” is ancient (orthos in ancient classical Greek meant both straight and correct, as in orthodox “correct belief”, orthodontics “straight teeth”). Likewise the idea of crookedness meaning “unconventional/bad/undesirable” is very old. Crooked politicians, someone being described as “twisted”, etc. Bent is a word used on UK English to mean homosexual. The exact etymology of queer is debated, but one major candidate is a Germanic word meaning “oblique”. Deviant itself comes from Latin roots meaning “off the way (road/path).
Essentially, proper people who stay on the road, follow the rules, behave in socially acceptable, conformist ways are “straight” and people who do not are bent, twisted, deviant.
Straight can also refer (especially historically) to people who don’t do drugs, non-hippies, sexually conservative people regardless of sexuality. The use regarding sexuality is an extension of this, especially juxtaposed to “bent”. Since gay is the most common contemporary word for non-hetero people, the connection is not as obvious, but gay also derives from associations of homosexuality with deviant behavior (in that case, sex work).
Latest Answers