This is a pun on 'naughty' which means (especially of children) disobedient; badly behaved, but 'knotty' is used in it's place because it sounds similar and because 'knotty' means to be full of knots which is what can happen to string when children play with it  
Children can do some knotty things with string .