Some leaves of a tree get detached when we shake its branches vigorously because branches comes in motion while the leaves tend to remain at rest due to inertia of rest.
When the tree is at rest, its leaves are also at rest. But when we bring the tree in motion by means of shaking it, due to the inertia of leaves they still tend to be in rest. Thus force is acting on leaves vigorously with changing direction rapidly. This results in detaching of leaves from the tree.