Seems to go way back to the B&W movie era - men in tuxedos, women in evening gowns and boas - glamorous socialites dressed to the nines, watching a couple buys beat each other up. Sometimes the MC is in a tux. I don’t get how that whole package goes together.
This I can at least guess at, typically you’d rise for important people to demonstrate that you are interrupting whatever you were doing and giving this person your full attention and respect. I guess that’s really just a show of dominance/submissiveness, but in a pragmatic sense I suppose it is a good practice to mandate focus and engagement during legal proceedings.