In theory classes, we're taught that an interval's acoustic consonance is a function of how "simple" it is as a ratio, where "simple" means being a ratio of small integers. So a perfect fifth (3:2) is consonant while a minor second (16:15) is dissonant.
But if you're slightly off a perfect fifth you might have a ratio of 3001:2000 or 2999:2000 which, by this "simplicity" criterion, should be extremely dissonant. Instead, we hear a smooth transition from consonance as we move away from a perfect fifth. Also, since there are always slight imperfections (however small) in performance, by this logic it seems like all music should sound acoustically dissonant. It clearly doesn't.
How is this explained?