I just recalled that in the Christmas Carol, Bob Cratchit's wife asked how Tiny Tim behaved in church, and Bob replied, " He was as good as gold, he was"! When Charles Dickens wrote this1843 novella, he may have "opened the door" to the use of the phrase as it relates to good behavior.