You may have or need a legal document (prepared by a lawyer or a firm of lawyers).
You may need legal access to your children in circumstances where they are not under your control (divorce).
You may face a legal challenge (being sued).
The court may have to listen to legal arguments from both sides before the case can proceed.
Anything that is legitimate needs to have a legal base.
Free speech is legitimate because the law says so but you have to be careful what you say in case you defame another person when you may face legal proceedings in court.
The legitimacy of everything we do depends upon whether there is a law prohibiting it or we are breaking a law in doing so.