Both misconduct and hindrances are perversions of the mind. It is inherently rooted in discontent and delusion, and perversion mentallly feels really good for one who is discontent and deluded.
Mendicants, there are these four perversions of perception, mind, and view. What four?
Taking impermanence as permanence.
Taking suffering as happiness.
Taking not-self as self.
Taking ugliness as beauty.
These are the four perversions of perception, mind, and view.
AN 4.49
The hindrances are less obvious perversions than the misconducts but they’re still perversions.
This is also exemplified in the agganna sutta, which shows sex in general as immoral, a misconduct, and not merely sensual desire
Those who saw them having sex pelted them with dirt, ashes, or cow-dung, saying, ‘Get lost, filth! Get lost, filth! How on earth can one being do that to another?’ And even today people in some countries, when a bride is carried off, pelt her with dirt, ashes, or cow-dung. They’re just remembering an ancient primordial saying, but they don’t understand what it means.
What was reckoned as immoral at that time, these days is reckoned as moral. The beings who had sex together weren’t allowed to enter a village or town for one or two months. Ever since they excessively threw themselves into immorality, they started to make buildings to hide their immoral deeds. Then one of those beings of idle disposition thought, ‘Hey now, why should I be bothered to gather rice in the evening for supper, and in the morning for breakfast? Why don’t I gather rice for supper and breakfast all at once?’
So actually the misconducts and the hindrances are both immoral and a result of a perverted view that takes pleasure in the immoral due to discontent. This is why a sense of shame is a requirement for upholding the virtues and by extension thwarting the hindrances, but a sense of shame can only come from right view.
Bhikkhus, ignorance is the forerunner in the entry upon unwholesome states, with shamelessness and fearlessness of wrongdoing following along. For an unwise person immersed in ignorance, wrong view springs up. For one of wrong view, wrong intention springs up. For one of wrong intention, wrong speech springs up. For one of wrong speech, wrong action springs up. For one of wrong action, wrong livelihood springs up. For one of wrong livelihood, wrong effort springs up. For one of wrong effort, wrong mindfulness springs up. For one of wrong mindfulness, wrong concentration springs up.
SN 45.1
The misconducts condition the hindrances because they’re all ultimately rooted in delusion which conditions the misconducts and in turn the hindrances.
It’s why one becomes appalled when one attains right view. Like the sutta with the prince in the palace going to bed with his mistresses, in the middle of the night a past life memory of him being a monk doing asubha meditation arises, he attains right view, wakes up disgusted at what he did with the mistresses,and in shock runs away from the palace and ordains. His perversion rooted in delusion was lifted.
The same goes for sensual desires perceived as burning coals for one with right view.
I also recommend reading Sakka’s question that made him become an ariya in DN 21, he asks where the unwholesome comes from and the Buddha shows the causation all the way to perception.
Thinking has the perceptions & categories of objectification[1] as its cause, has the perceptions & categories of objectification as its origination, has the perceptions & categories of objectification as what gives it birth, has the perceptions & categories of objectification as its source. When the perceptions & categories of objectification exist, thinking comes into being. When the perceptions & categories of objectification are not, it doesn’t."
…
Objectification = papañca. The tendency of the mind to proliferate issues from the sense of “self.”
So this goes back to perversion of the 4 perceptions quoted above. The perversion of perception “seeing no-self as self”, is the same as the poison of delusion which is identity view and conceit.