The 6th Amendment was written to prevent secret courts. The English Star Chamber was frequently secret and you could be put on trial without knowing what evidence/testimony was brought against you. The Star Chamber was also why the 5th Amendment exists.