You should wear business or business casual attire to court.
Lawyers are required to wear business attire, and typically will wear a suit when appearing in court. The court process is very formal, and there are many rules and traditions that govern how lawyers, clerks, and judges appear and comport themselves in the courtroom.
Witnesses and accused individuals are not required to dress in any particular manner while appearing in court. If you are required to attend court, however, dressing appropriately in business or business casual attire will signal to the judge and to other participants in the criminal justice system that you are taking the case seriously by demonstrating respect for the court.