Most of the time children are looked after according to the agreement between the parents. But sometimes parents just cannot reach an agreement, and thus the court has to get involved and make orders.
Whenever a court has to deal with anything in relation to a child, the court is directed by law to give first priority to the needs of the child, rather than the needs or wishes of either of the parents, or indeed anybody else.
So, for example, the issue of where the child lives and how much contact other people have with the child is not regarded as a matter of rights for those people concerned. It is regarded rather that the child has a right to see its parents in appropriate circumstances, so the court is deciding how best to give effect to the child's rights, not anything to do with the rights of any parents, or whoever it may be.
In deciding what the best order to make will be, the court will be greatly assisted by reports from officers of what is now called CAFCASS. These used to be called 'court welfare officers', and in practical terms that is probably still a useful phrase to use. They will usually go and see the child, speak to the parents, and so on, and prepare a report for the court.
In preparing that report they will consider what is called the 'welfare checklist', which covers such things as what the child wants, which obviously depends to a degree on how old the child is; what are the child's needs, physically, emotionally and educationally; whether there might be any change of circumstances that is relevant; the age, sex and background of the child; and any other characteristic that might be relevant, such as, for example, any disability; any harm which the child has already suffered or might be at risk from suffering; and the capabilities of the parents to meet the child's needs.