Looking to make some hay? No problem. Just cut some grass, clover, or alfalfa, and spread it out to dry. To speed things up, do so while the sun shines (c.1546) — which of course means making the most of an opportunity by taking full advantage of it before it passes.
You also should pay attention to the possible consequences of your actions — the aftermath that is. The "math" in this instance, however, does not add up. Its relevance instead derives from the Old English word for "a mowing" or a "crop gathered by mowing." When you take the first part of the Old English verb, mawan, "to mow" and add the suffix -th. — as with "grow," thus creating grow-th, "a growing" — we similarly created an "after-a-mowing" or "second mowing" — a crop of grass that grew up and meant to be cut after the first had been harvested as an aftermath. We liked the idea so well we later adapted the word as an appropriate figure of speech for after-effects or consequences in general.
"What the hey?" (c.1932), you say, meaning, "What's going on here?" or "Who really cares anyway?" The answer is, "Not much, and nobody," when you really "come down to it."
One thing's for sure though: That ain't hay! (Early20thC.) — "a great deal of anything, mostly money." There's lots of hay around, and it's not worth much, except to the cows. Comparing anything else to it makes the other item seem even more valuable.
As to the aforementioned "hey," it's simply a euphemism for "hell." Perhaps that's why it always annoyed my mother whenever I prefaced my remarks to her with, "Hey, Mom..." Her retort was always, "Hay is for horses." Mine was simply, "Hey, why not?"