(For Groot, as Vin Diesel might say).
If you're a koala, hugging a tree helps cool you down on hot days. It also works for leopards...and even your own house cat (so if your cat climbs a tree and flops on a branch, they're probably feeling the heat).
And, yes, chimps do it too. Humans? With no body hair, the effect - the tree's circulation pulling heat away from the animal - might be even more pronounced. Our ancestors likely hugged trees to cool down on warm days and possibly even to warm up on cold ones (although as we originated as a tropical species...)
So, go ahead. Hug a tree on a hot day. You never know, it might help you feel better.