The proverb is similar to Necessity knows no law, but it is also as an excuse for not resisting temptation.
‘Needs must’ is used here without ‘do’, which completes the phrase. ‘Needs must do’ is synonymous with ‘cannot avoid doing’.
‘Why do you drink so much? You never seem to be sober.’
‘I can’t break myself of it. It’s a question of needs must when the devil drives.’