A formal written or spoken statement, esp. one given in a court of law
The expression comes from Anglo-Norman Middle English. A court of law is a place, hall, or chamber in which justice is administered.
You will also find the word in court of justice, court of judicature or the Supreme Court.
It was used in the middle ages in many occurrences where important institutions where to be found. See for instance the king's court - from which it then gained the meaning of "retinue".
Beyond Old French, Spanish and Italian, the origin can still be traced back to the Latin "cohort-em" which means yard or enclosure. In modern French it has lost its final "t" and is now spelled just "cour".
you can't separate out the "law" from "a court of law". It is a set phrase. You could just say "in court", but not all proceedings in "a court of law" take place in the court room these days.
The phrase a refers to the location and proceedings of a legal tribunal.
A court of law in the one sense is a physical place. It is the building in which the judge presides over a case of legal debate.
In the other sense, a court of law is the abstract situation, referring to the authority that the judge represents while presiding over said tribunal.
The House of Commons and the House of Lords formally make up the High Court of Parliament. There are also the courts (short for courtyards) in Oxbridge colleges and similar places, and "student courts" where student unions impose discipline without formal authority, so not all courts are courts of law.
There is also the technical point that only courts of law have the right to impose legal sentences. Tribunals, mediators, and local councils cannot fine or imprison people. (It's a technical point because, for example, the owner of a carpark cannot fine you for parking in the wrong place, but he can tow away your car till you pay what's due).