Depending upon the age and maturity of the child, the court may take the child's wishes into consideration, but generally the courts do not want the child involved in this decision. The court may appoint a Guardian Ad Litem to represent the best interests (not stated desires) of the child in the process, or appoint a parenting evaluator (M.S.W. or Psychiatrist or Psychologist) to make a recommendation to the court as to the child's best interests. Again, depending upon the age of the child, these experts may ask the child questions like how they get along with each parent or what they like to do with each parent, but will usually not ask the child who they want to live with, as that is an inappropriate question.
There are many reasons a child should not be asked this question. Generally, children want to live with both parents in a happy family, which is no longer an option. Younger children will tell both parents in private that they want to live with them, because that is true, and they don't want to hurt their feelings. It is not appropriate to force a child essentially reject one parent in this legal process they had nothing to do with. Older teens can pit one parent against the other, saying if you give me ____ (bicycle, car, etc.), then I will say I want to live with you. We cannot give children that kind of authority, or the parents will lose all authority.
This is the decision of the parents, not the child. If the parents cannot agree, then the courts are there to decide.