As a general rule, " 's" indicates possession, whereas "of" indicates a general property of an object (which can include possession, giving them some overlap). If you use "A's B", you should be able to rearrange the sentence to "A has a B".
For example, you can't say "secrets' chamber", because a secret can't own anything i.e. "The secret has a chamber" makes sense grammatically, but practically speaking it doesn't make any sense.
You CAN say "The barber has a knife", so you can say "the barber's knife". "The knife of the barber" is also possible and it means the same thing.
"A of B" can describe the properties of something, including origins, who owns it, what it's made of etc. "The barber's knife" can only mean "the knife that the barber owns". "The knife of the barber" could also be interpreted to mean a knife which was made from the bones of a barber, or it's a knife that magically turns the owner into a barber; but they're completely ridiculous, so we can rule them out immediately.
If you say someone has a heart of gold, it means that they're a nice person with good intentions. It doesn't literally mean that their heart is made of gold; but if you did interpret literally, that's what it would mean. "Gold's heart" makes no sense though - gold can't own anything (i.e. you can't say "The gold has a heart"), so "gold's heart" is meaningless (although you could use "golden" as an adjective e.g. "He has a golden heart").
You might hear that " 's" can only be used for people, but that's not strictly correct. You could say "my country's people" or "my jacket's pocket", but only because you could say "My country has people" or "My jacket has a pocket".