Maybe it goes beyond some people's sensitivities today, but for some time I've theorized that part of McCoy's "needling" of Spock was literally for the half Vulcan's physical and psychological well being. Maybe earlier in his career, Bones studied the case file for Spock, his being a gene spliced hybrid. Maybe some members of the original medical team who assisted and monitored his gestation, birth and early development noted that Spock should NOT favor the cultural norms of one species to the total exclusion of the other as that could &^%$ up a very delicate hormonal balance (i.e. totally suppressing his emotions, or even the opposite).
When McCoy takes his position of chief medical officer aboard the Enterprise, he reviews the records Boyce wrote that in summary stated, "Spock is not your 'average' Vulcan. Don't let him bottle his emotions. It can make him literally sick if not possibly kill him!" So, in his less than "silk glove soft" bedside manner, McCoy is urging Spock to "lighten up", if only for purely medical reasons.
That's my take on it, anyway. And, as Beaker pointed out, close friends can sometimes be the most caustic towards one another rather than with strangers.