All my life I’ve understood this proverb only in a context, and even then, not entirely. So, prompted by your question, I looked it up:
From Wikipedia, the free encyclopedia
You can’t have your cake and eat it (too) is a popular English idiomatic proverb or figure of speech. Many people misunderstand the meanings of “have” and “eat” as used here but still understand the proverb in its entirety and intent and use it in this form. Some people feel this form of the proverb is incorrect and illogical and instead prefer “you can’t eat your cake and have it (too)”, which is in fact closer to the original form of the proverb but very rare today. Other rare variants use “keep” instead of “have”.
The proverb literally means “you cannot both possess your cake and eat it”. It can be used to say that one cannot or should not have or want more than one deserves or can handle, or that one cannot or should not try to have two incompatible things. The proverb’s meaning is similar to the phrases “you can’t have it both ways” and “you can’t have the best of both worlds.” Conversely, in the positive sense, it refers to “having it both ways” or “having the best of both worlds.”