It comes from "My Lords, Ladies and Gentlemen". Titled men come first (My Lords); then their spouses [My] Ladies; Ladies also include non-titled ladies; and finally, untitled men (Gentlemen). Debretts, Preamble Precedents
The following list gives the form in which important guests should be
included in a preamble in order of precedence:
Your Royal Highness
My Lord Mayor (My Lord Provost, etc) See (i)
Mr Recorder (outside London)
Mr Chairman of the ...... County Council (outside Greater London)
My Lord Chancellor
Prime Minister (or, more formally, Mr. Prime Minister). See (ii)
Your Excellency (ies) (this refers to Ambassadors and High
Commissioners)
Your Grace(s). See (iii)
My Lord(s). See (iv)
Ladies and Gentlemen. See (v)
If you want to know what the footnotes (i) through (v) say, so you will be absolutely correct at your next speech, click on the link.