The sodomites in Canto XV and XVI of the Inferno are being punished because they committed sins of lust and indulged in unnatural sexual acts. Dante and Virgil exhibit an unusual attitude because Dante is sympathetic towards them, recognizing the societal factors that may have influenced their actions, while Virgil maintains a more objective stance, adhering to the divine justice that condemns their sins.