Why is it considered improper to directly add an `onclick` attribute to an HTML element? From a Drupal perspective, why is it considered improper to directly add an onclick attribute to an HTML element instead of using a Javascript behavior?
There's a good answer in the JavaScript subreddit on reddit here. To summarise, here are the reasons provided:


  
  tight coupling between presentation and behavior
  code runs in the global scope
  makes testing and debugging difficult
  defies progressive enhancement
  quickly becomes hard to maintain
  also it will unbind any previously assigned click handlers which might be an unwanted side effect
  


Maintainability and testability are the major killers for me here.

There's not much more to add to give a Drupal specific answer. The only two things that comes to mind are the following:


Behaviours are automatically re-applied to any content loaded via AJAX, so if you have an AJAX powered view the click handler will be rebound for you without having to have the function in the global scope.
You don't have to try and locate templates, or hack away at anything just to add a new attribute to an element. For example, if you want a click handler on a node title link, you have to update the template. If you then add a new view mode, but still want to have the click handler listening, then you need to ensure the onClick is on that element as well - this increases the maintenance time and risk of error. If you just use a behaviour, then you can hook onto the title link class and it'll work everywhere.