That's the way the cookie crumbles

Read the Wiktionary entry "that's the way the cookie crumbles" You can also: The origin of this expression is unknown but it has been in use since at least the 1950s.

It is a variant on the expression "that's the way the boerewors bends".

"That's the way the boerewors bends" appears to have originated in the 18th century