This is likely a melee mechanic for boss monsters in creep packs. For consistency, creeps do not use heroes, which would have also had the desired effect. The entire creep player also has a ton of hard coded logic and behaviour which can result in some rather strange interactions such as them being unable to attack buildings too far away from their camp.
Without this mechanic it would be far too easy to trivialise such creep units by keeping them constantly CCed and so unable to resist effectively.
The idea behind this mechanic is taken to the extreme with the really tough creep monsters which usually have abilities like divine shield (bandit lord?), or are out right spell immune (golems, dragons, e.t.c.).