When I worked for the park service, my botanist boss told me that the reason junipers and that sort of scrubby, stress-tolerant tree have twisty trunks is so that if they lose a section of roots they don't lose a sector of sunlight in the canopy. Because sunlight can be focused on one side of a tree (especially if growing on a steep slope), a twisting trunk can save a tree in the case of root damage on one side.