That's because the tail DOES have pain receptors, but they do not react the same when relaxed as when excited.
By the way, just because a dog does not feel pain does not mean they cannot do damage.
Many a dog has damaged their tail, split is open, or done other things to it while furiously wagging the tail.