Why does the Buddha, in the Pali Canon, periodically engage in harsh speech?
The answer to this comes in the Kesi Sutta:


  As he was sitting there, the Blessed One said to him: "You, Kesi, are
  a trained man, a trainer of tamable horses. And how do you train a
  tamable horse?"
  
  "Lord, I train a tamable horse [sometimes] with gentleness,
  [sometimes] with harshness, [sometimes] with both gentleness &amp;
  harshness."
  
  "And if a tamable horse doesn't submit either to a mild training or to
  a harsh training or to a mild &amp; harsh training, Kesi, what do you do?"
  
  "If a tamable horse doesn't submit either to a mild training or to a
  harsh training or to a mild and harsh training, lord, then I kill it.
  Why is that? [I think:] 'Don't let this be a disgrace to my lineage of
  teachers.' But the Blessed One, lord, is the unexcelled trainer of
  tamable people. How do you train a tamable person?"
  
  "Kesi, I train a tamable person [sometimes] with gentleness,
  [sometimes] with harshness, [sometimes] with both gentleness &amp;
  harshness.
  
  "In using gentleness, [I teach:] 'Such is good bodily conduct. Such is
  the result of good bodily conduct. Such is good verbal conduct. Such
  is the result of good verbal conduct. Such is good mental conduct.
  Such is the result of good mental conduct. Such are the devas. Such
  are human beings.'
  
  "In using harshness, [I teach:] 'Such is bodily misconduct. Such is
  the result of bodily misconduct. Such is verbal misconduct. Such is
  the result of verbal misconduct. Such is mental misconduct. Such is
  the result of mental misconduct. Such is hell. Such is the animal
  womb. Such the realm of the hungry shades.'
  
  "In using gentleness &amp; harshness, [I teach:] 'Such is good bodily
  conduct. Such is the result of good bodily conduct. Such is bodily
  misconduct. Such is the result of bodily misconduct. Such is good
  verbal conduct. Such is the result of good verbal conduct. Such is
  verbal misconduct. Such is the result of verbal misconduct. Such is
  good mental conduct. Such is the result of good mental conduct. Such
  is mental misconduct. Such is the result of mental misconduct. Such
  are the devas. Such are human beings. Such is hell. Such is the animal
  womb. Such the realm of the hungry shades.'"
  
  "And if a tamable person doesn't submit either to a mild training or
  to a harsh training or to a mild &amp; harsh training, what do you do?"
  
  "If a tamable person doesn't submit either to a mild training or to a
  harsh training or to a mild &amp; harsh training, then I kill him, Kesi."
  
  "But it's not proper for our Blessed One to take life! And yet the
  Blessed One just said, 'I kill him, Kesi.'"
  
  "It is true, Kesi, that it's not proper for a Tathagata to take life.
  But if a tamable person doesn't submit either to a mild training or to
  a harsh training or to a mild &amp; harsh training, then the Tathagata
  doesn't regard him as being worth speaking to or admonishing. His
  knowledgeable fellows in the holy life don't regard him as being worth
  speaking to or admonishing. This is what it means to be totally
  destroyed in the Doctrine &amp; Discipline, when the Tathagata doesn't
  regard one as being worth speaking to or admonishing, and one's
  knowledgeable fellows in the holy life don't regard one as being worth
  speaking to or admonishing."