The Sixth Amendment guarantees the right to a public trial. Like the right to a speedy trial, the right to a public trial serves the interests of both criminal defendants and the public. Defendants are protected from secret proceedings that might encourage abuse of the justice system, and the public is kept informed about how the criminal justice system works.
Like most constitutional protections, however, the right to a public trial is not absolute. A criminal defendant may voluntarily give up (waive) his or her right to a public proceeding or the judge may limit public access in certain circumstances. For example, a judge might order a closed hearing to prevent intimidation of a witness or to keep order in the courtroom. – The United States Constitution, What It Says, What It Means, A Hip Pocket Guide