Historically, what would happen if a church could not afford or provide wine for the sake of the Eucharist? I assume that at some point in the 2000 year history, there were churches that found it hard to obtain wine at some point. What did the church teach could or should be done in these situations?
You question is based on a few assumptions, let's go over them:
First, a Catholic eucharist can't just use any wine. There are strict rules for its origin and production laid down by the Vatican. Essentially, sacramental wine has to be:

Made naturally, “from the fruit of the grape, pure and incorrupt”—though raisins are also permissible.
Not mixed with other substances, though a small quantity of water is mixed in during the ritual
not turned into vinegar or soured

It is altogether forbidden to use wine of doubtful authenticity or provenance.
Strangely, sacramental wine can actually be red or white, dry or sweet, even fortified, as long as the source of fortification is also grape-derived, and as long as the ABV stays between 5 and 18%.
Once it’s approved by a bishop of the vineyard’s diocese, it can be labelled “sacramental”.
Second, not all Catholic churches, now or in history, serve wine to the laity during (every weekly) Eucharist. The rule governing the minimum frequency of receiving communion nowadays is based on Canon 920, based on the Pio-Benedictine Code (1917 CIC 859), which in turn rested on legislation going back several centuries at least to the Fourth Lateran Council in 1215.
Third, during epidemic periods in history, the consumption of wine (and in some cases also bread) was taken out of the ritual. An example of this is the 1547 Sacrament Act, introduced after the plague, which requires both bread and wine to be given “except necessity otherwise require”. This and similar rules have also recently been invoked by churches as a response to the COVID-19 pandemic.
The inverse (preferential exemption) has also occurred. During prohibition, consumption of Christian sacramental wine was exempted from prohibition laws, while -for example- Jewish kiddush was not.
Lastly, the relevance of consumption from the perspective of the laity has also declined in the last century or so. According to a recent Pew Research survey, the majority (69%) of Catholics in the US believe that the bread and wine of the Eucharist are merely symbolic and not transubstantiated, the very belief which makes the consumption essential to the ritual. Maintained belief in transubstantiation is highest in the oldest living generations (38% compared to the average 29%).