This quote, often misattributed to Twain, is meant to be humorous and satirical. It criticizes the idea that simply obtaining a degree guarantees intelligence or competence.
However, there's no record of Twain actually using this specific phrase. The closest thing we have is a similar quote from his work "A Connecticut Yankee in King Arthur's Court" where he writes about a character who is "as empty as a blasted gourd, and as ignorant as an unlettered clod."
While the cabbage analogy is likely not from Twain, it still effectively highlights the potential for people to gain a degree without acquiring genuine knowledge or understanding.