Saying "We buy X at where it is cheapest" means "The cost of X at the places where we buy it is as cheap as X would be anyplace else". Saying "We buy X where it is the cheapest. would mean "We buy X at places where it is cheaper than other products those places sell".
Suppose one prefers beverage Y to brand X (or any other alternative)--not by so much as to pay a significant price premium, but enough that if both products are essentially the same price one would much rather have Y. At store #1, X costs $4 and all other brands cost $6; at store #2, all brands cost $2. Other stores charge $3 for all brands. Given a choice of where and what to purchase, one would buy Y from store #2 for $2. Sometimes however, one might get thirsty while stuck in store #1 and, in that case, one would buy X for $4. Note that under that scenario, one would never buy X where it was cheapest (which would be store #2) but only where it was the cheapest (which would be the store where buying X was most expensive).
Effectively, the use of the article changes the meaning of "it". When the article is omitted, "it" refers to the act of purchasing, which is compared against other hypothetical acts of purchase; when the article is included, "it" refers to the thing purchased, compared against other hypothetical things that could be purchased.