The interval of F# to A is a minor third, an imperfect consonance. But if we spell the F# as a Gb, suddenly we have created an augmented 2nd, a dissonance. Sonically, these two situations are the exact same thing. Their frequency ratios are exactly the same, the only difference is that they are spelled differently. However, this sonically nonexistent difference somehow changes a consonance to an interval that is considered dissonant. This is not limited to this one situation; the augmented fifth, diminished 7th, and diminished fourth all have consonant equivalents, and yet are somehow considered dissonant. How does spelling change an interval's consonance?
The spelling doesn't make it dissonant or consonant; the consonance or dissonance determines the spelling.
Rather than spell the notes, assign them numbers: C = 0, C# = 1, D = 2, ..., B = 11.
Now consider the C minor scale. The first three pitches are 0, 2, 3.
The E harmonic minor scale also contains 0 and 3:
4 6 7 9 11 0 3 4.
However, if one plays the two scales, the 0-3 in the C minor scale has a very different character than the 0-3 in the E harmonic minor scale.
In order to reflect this contextual different in sound, the otherwise enharmonically equivalent pitches are given different spellings:
C D Eb for the C minor context, and
C D# E for the E harmonic minor context.
Also, historically, before equal temperament was standardized,
Db, for example, were not necessarily the same pitch. Even today, instruments with "continuous" tuning ability, like violin or voice, will adjust notes sharp or flat —that equal temperament would otherwise deem equivalent — to create better intonation of intervals in specific contexts. For example, the minor third or a chord might be adjusted very slightly higher, or the major third very slightly lower, bringing them closer to their just-intoned equivalents.