In baseball, this phrase refers to any illegal action performed on the ball in order to affect its delivery to the batter. Before rules specifically outlawed them, the following activities would sometimes be performed by pitchers in order to help their pitches: applying saliva or Vaseline to the ball; scuffing the ball with sandpaper or an emery board; or using cloth to create a shine on one side. The effects of these modifications varied, but in general, they would either slow the ball down or affect its spin.
The phrase "doctoring the ball" comes from the perception that a pitcher is performing "surgery" on the ball. Major League Baseball outlawed any doctoring of the ball in 1920. There were many infamous instances of doctoring the ball which adversely affected the game and caused embarrassment for the league. There are very stiff penalties for any pitcher caught doctoring the ball, but nowadays such actions are much more difficult to get away with and extremely rare given the heightened media scrutiny that surrounds modern day baseball.