When something takes the cake, it is an outrageous example of something bad. For example, you might say, "Stealing your own child's Halloween candy really takes the cake!"
Originally, to take the cake meant to win a prize or a competition — people as far back as the ancient Greeks used the word cake to mean "a symbolic prize." Over time, it grew to have a more negative, sarcastic meaning in English: "I can't believe this mess. It just takes the cake." A common variation is to take the biscuit.