The why is easy, any time the parents of children do not agree on where their children should live, a judge decides. Getting to a decision is a long road. It means opening and filing into a court case and going through a complex process leading up to a trial. At trial, the judge will listen to both parents and anyone else who may be involved with the children who will then come to a decision. If you want to keep the judge out of your personal business, make an agreement with the other parent.
How does the judge decide? That is a little more complex. The decision is not based on what is fair for the parents or easy for the parents, but it is based on what is best for the children. Minnesota law, specifically section 518.17 of the state statutes, sets out the factors that judges are required to consider in making a custody decision. While the statute is clear in listing the factors, how they are actually applied is complex and varies with each case depending on the circumstances of the parents. If you are heading into a custody battle, know the factors and more importantly, know how your local judge is likely to apply them.