The bar is the railing that separates the audience area (called the gallery) from the area with the attorney's tables (called the well). So the people who are allowed past the bar became known as "the bar", just like how judges (who sit at the desk at the front of the courtroom called the bench) became known collectively as "the bench". "Passing the bar" has both a literal and figurative meaning. Literal being that the person passed a test called the bar exam, but also figuratively being that they are now permitted to pass the bar in the courtroom.
The bar is the railing that separates the audience area (called the gallery) from the area with the attorney's tables (called the well). So the people who are allowed past the bar became known as "the bar", just like how judges (who sit at the desk at the front of the courtroom called the bench) became known collectively as "the bench". "Passing the bar" has both a literal and figurative meaning. Literal being that the person passed a test called the bar exam, but also figuratively being that they are now permitted to pass the bar in the courtroom.