It was first invented when a high school student working at Taco Bell said to her friends "Cool Beans" instead of saying "Cool". She thought of this term because she was making burritos everyday, and she was handling beans on a daily basis.
I bought a new dress.
It is also used by Creed Bratton of The Office.
Unimpressed listener: Cool beans
YOU: "Cool beans."
kid 1: "you know what sucks?"
kid 1: "my gf dumped me"
YOU: "cool beans."
(a way to lose a friend quickly)