‘A piece of cake’ means a work that is too easy or simple and requires hardly any effort. The term was probably originated in the 1930s but came into daily usage when popular American poet Ogden Nash first used it in the year 1936 in one of his creations. The coinage is pretty simple and easy to understand. Though a delicious piece of cake or a pie is not that easy to prepare, but it hardly takes any time or effort to consume them. So the ease of eating such a tempting thing has probably given birth to this idiom. For example:
The test was a piece of cake for me.