One has to be very careful in using Google Ngrms or Google Books to judge current frequency of use. Republication of older works, and quotes in recent works from older texts can distort the frequencies. And the patterns of use in books may not be the same as in, say newspapers, or in spoken use.
Even more, one should be very reluctant to deduce general rules from a few specific examples of this sort. Usage is notoriously inconsistent, and often does not follow any clear or logical rules. What form is most common may be a matter of historical accident, including the imitation of some popular or well-known text.
What one can say with assurance is that "Drinking coffee" and "having coffee" are both in reasonably common use, and have generally similar meanings. Either might be used by, and would be understood by, a fluent speaker. The same is true for "eating food" and "having food", and for many similar alternates such as "taking a bath" and "having a bath". Which to use is a matter of style and nuance in a particular text.