Because historically, a "sharp" note was thought of as a leading tone (Ti), whereas a "flat" note was thought as a fourth scale degree (Fa), tending to step down to the third (Mi).
(Actually, this was thought of most often in terms of hexachords, where there is no Ti and one would always use Mi-Fa for a half-step interval. I rewrote it in terms of scale degrees to avoid confusion.)
I.e. the F# in Gmaj does "want" to step up to G, in basic structural terms. We call the places where this happens most properly "cadences", and they are among the main structuring elements in a piece of music. (This Ti-Do - F#-to-G or B-to-C motion is then called a "cantizans", since it appears most prominently as a "canto" or "sopran" cadence. It's most typically seen as Do-Ti-Do, where the first appearance of Do is first "prepared" in a context that makes it a consonance, but then sounds as a dissonance as the other parts shift to a dominant chord (Sol and Re), so it's allowed to resolve to the leading tone.)