Any material used to modify another substance has been called a 'dope' for a long time; silicon is 'doped' to produce semiconductors, for instance.
People who modified their mood with narcotics were therefore called 'dopers', which later became 'dopes'. 'Dope' became a synonym for 'fool' because fools used dope, not the other way around.