why would a crown prince know a court jester well?

Why?

Read on, sjm, just one sentence further. Why? Because this jester "hath borne me on his back a thousand times ... Here hung those lips that I have kissed I know not how oft".

It is Yorick who is fondly remembered here, not Horatio. Horatio is nothing more than a prop on this occasion, irrelevant to Hamlet's reminiscence.

Again we see the art in the misquotation, sjm:

"Alas, poor Yorick, I knew him well" adds to the original what is necessary and implied, and subtracts from the original what is irrelevant and distracting.

In the process, it becomes a badge of grief for the loss of someone dear, communicating emotions which are totally absent from the original when excised from the Play.

Shakespeare would surely approve.

Thank you, sjm, for providing so vivid a proof of the axiom I have stated so boldly. [I worried that I might be skating on thin ice but you have convinced me otherwise.]

BTW I have never encountered "A rose by any other name would smell as sweet" before. I take your word for it that some people use it, but it has not become a standard substitution [thankfully] and, therefore, it does not abridge our rule.