In 1 Samuel 28, we have the story of King Saul visiting a woman in Endor. Leviticus 19:31, 20:6 are prohibitions in turning to ghosts and familiar spirits. Are these prohibitions in place to prevent people from being "suckered" by frauds who claim they can communicate to the "other side", or are the prohibitions in place because some people can communicate with ghosts and familiar spirits? In the case of Saul speaking to Samuel, was it (a) actually Samuel (b) a demon masquerading as Samuel, or (c) the Woman in Endor putting on a good show?
Maimonides in the Laws of Idol Worship (XI 16) is emphatic in teaching that the prohibitions do not forbid something real and useful- the magic and witchcraft are nothing more than "lies and deceit". The success of these magicians was based on a sense that they had of what was about to occur, based on a heightened imagination (Iggeret Teiman). Even so, this sense made their hunches more accurate than those of others but still they were very often wrong. The Radak in his commentary on Samuel I writes that there are those who feel that the magic "works" (athough they too agree that, unlike true prophecy, it is not reliable). One opinion is that the woman in Endor was about to perform her usual sleight of hand and was shocked when, by a miracle unrelated to what she was doing, Samuel actually appeared to Saul.