An empirical approach
When we hear two musical notes played together (either in succession, or simultaneously), we often characterize those notes as “dissonant” or “consonant”. But instead of having a sharp dichotomy between dissonance and consonance, it might be more useful to speak of a spectrum between the two. Then, the question before us is how to quantify the dissonance of any pair of notes.
12tone is a cool music theory channel, and he recently published a video discussing the solution thought up by the 18th century mathematician Leonhard Euler. I include the video below, but be warned that I’m going to trash Euler’s answer. I believe that any measure of musical dissonance must, at some point, refer to empirical observations of dissonance. Euler’s answer relies on mathematical supposition, and thus I would deride it as numerology.