Multiple realities
(covers information from several alternate timelines)
For the comic, please see Bones (comic).

Bones was a nickname for Doctor Leonard McCoy in multiple realities.

In the prime reality, Bones is short for "Sawbones"; the term was used by James T. Kirk almost exclusively to refer to Leonard McCoy during their service together. (TOS: "The Man Trap", "A Piece of the Action"; Star Trek VI: The Undiscovered Country)

During a 2267 landing party mission on Pyris VII, Kirk made a special point to avoid calling McCoy "Bones", instead using the nickname "Doc", after finding themselves in shackles hanging alongside a skeleton. (TOS: "Catspaw")

In the alternate reality, James T. Kirk refers to Leonard McCoy as Bones because, as mentioned by the doctor the first time they met, all his ex-wife left him after their divorce was his bones. (Star Trek)

The use of "Bones" originates with the term "sawbones" in 19th century American medicine where military doctors, especially surgeons, were called "sawbones" because of all the amputations they had to perform during the Civil War. The nickname appeared in Gene Roddenberry's original Star Trek pitch as the nickname for Philip Boyce, but was never used in "The Cage".
According to J.J. Abrams in his DVD commentary, the line explaining the nickname in the alternate reality was not scripted - Karl Urban, a Trek fan long before being cast as the doctor, thought of it while filming the scene.