Answers

It’s mainly a protective layer, kind of like insects’ and other arthropods’ exoskeleton. The dangers that the tree bark helps against include phenomena like dehydration and fire, as well as damage by other organisms such as parasites and herbivores. Most of this is accomplished merely by having an extra layer, although some plants have special chemicals in the bark that kill fungi and bacteria that cause decay.