Where does the phrase sick to my stomach come from? Never stopped to think of it before. It doesn’t even seem grammatically correct.
Google n-gram shows it showing up around 1890 for the first time. Here's an editorial from 1905 where a reader asks the same exact question you have. The editor's explanation is that the speaker means it for emphasis or inclusiveness: i.e., not just sick at their stomach, but from somewhere (head, mouth, somewhere else) through and including their stomach.
I voted to close as Not Constructive (as Bill Franke says, it's an idiom, so concepts of present-day "grammaticality" don't really come into it). But I disagree with the only existing answer, so...
I stopped the chart at 1970, but if you just look at the last 60 years (when most of us were learning English), it's pretty obvious the switch to "to" rather than "at" has been almost unanimous. Even the relatively tiny number of instances in modern times probably includes a significant proportion that are just citations of earlier usages.
I'd also note that OP may be thinking primarily (or only) of the now-ubiquitous (I'm exasperated) sense. That's a trivial metaphoric extension which could have applied at any time in the past - it's just that we use it a lot more nowadays...
The particular choice of preposition isn't governed by any considerations of grammar. Possibly the current preference for "to" is influenced by analogy to related expressions like I've had it up to here (which as that NGram shows, also really took off after the war).
There really is nothing unusual about such shifts in idiomatic usage, nor is there anything unusual about the fact that natural "lag" sometimes means the version we actually use doesn't fit perfectly with our more general concepts of "grammaticality" at any given time.