AllenT may have a good answer. Depends on the book. It could also be a slur, a reference to the person's lack of ability (Halfy = having half the expected ability), or a reference to the person's size (Halfy = having half the expected height), as in J.R.R. Tolkein's "Lord or the Rings" trilogy, when the hobbit characters are called "half-lings" by people of normal, human size.
Again, it depends on the book.