My theory is that it originally was a French Canadian, or American Cajun, expression: "beaucoup bien" meaning literally "a lot of goodness" . It then became anglicized by absorption into neighbouring English speaking communities.
"Beaucoup bien" .. " 'coup bien" .. "cool beans"