how can we theoretically understand that chords are compatible? let's imagine that there is a chord X1 and X2, what rules/conditions must these chords follow in order to be compatible? I have a similar question about dissonances, because their good sound depends on the context, but how is this explained theoretically - is there any algorithm to check the compatibility of chords?
upd: Let's just imagine that we are standing at the piano and I am playing two chords at the same time, the question is: "why do they sound harmonious?", or vice versa: "why don't they sound harmonious? ", or even like this: "why does this dissonance sound normal with such chords? ". Everyone had a moment when you made a mistake in the note when playing and it sounded terrible, but where is this line between bad and normal? Where can I find a theoretical answer/musical algorithm like: "with such a chord, such notes/chords will sound bad"...or..."being in such a scale or key, such notes will sound bad" (please, please don't talk about the quarto-screw circle - there are too few variations)