The term has its origins in the Q code used for commercial radiotelegraph communication, and later adopted by other radio services, especially amateur radio. The first number is the answer to the question "How do you receive me?" (Q code QRK), typically answered with "I am receiving (15)" where 1 is unreadable and 5 is perfect. The second number is the answer to the question "What is the strength of my signals?" (Q code QSA), typically answered with "The strength of your signals is ... (1 to 5).". "5 by 5" was the answer to the QRK/QSA questions to indicate the best quality signal. "5 by 5" being the best quality was applied to other things by analogy.
Not many, if any, know that the Q CODE is for radio communications.
https://en.wikipedia.org/wiki/Q_code
.... .. .... .. -.-
I know, and I don’t understand why it was ever a question what “5 by 5” means. But then, I was a Boy Scout in the nineteen fifties.