James wrote fiction in an era before the modern technique of the "stream-of-consciousness" was established. In the modern technique, the author feels free to go inside the mind of the character. But in James' time, this was not yet an established technique. Since James as a novelist wanted to remain outside the novel — that is, wanted to present his characters with as much objectivity and realism as possible — he created the use of a confidant.
The confidant is a person of great sensibility or sensitivity to whom the main character reveals his or her innermost thoughts (as long as they are within the bounds of propriety). The confidant is essentially a listener and in some cases an adviser. This technique of having a confidant to whom the main character can talk serves a double function. First of all, it allows the reader to see what the main character is thinking, and second, it gives a more rounded view of the action. For example, after something has happened to the main character, the confidant hears about it and in the discussion of the event, we, the readers, see and understand the various subtle implications of this situation more clearly.
The confidant is also a person who is usually somewhat removed from the central action. For example, Mrs. Costello never meets Daisy Miller but she serves as a listener to Winterborne and offers her own view about Daisy. Likewise, Mrs. Grose in The Turn of the Screw has never seen any of the apparitions, but she serves as the person to whom the governess expresses her doubts and fears. Thus, essentially the confidant observes the action from a distance, comments on this action, and is usually a person of some exceptional qualities who allows the main character to respond more deeply and subtly to certain situations.