Interesting question... I dont have the answer, but remember seeing a lot ofthat growing us.. not so much any more.. so I will subscribe to this one, and wait for an answer also!
Your grandpa was smart! I remember seeing a lot more painted trunks when I was a kid than I do now.
The white paint protects young bark from sun scald in the summer, and in the winter reflects the sun to keep the bark from splitting.
The bug it protects against would probably be borers since they prefer weaker bark, or splits caused by sun scald or frost cracks.
If you do it be sure to only use latex interior paint, oil paint will poison the tree and some exterior paints have fungicides.
Saw on citrus trees in Phoenix and was told it was to protect the bark from the sun. I suppose in other parts of the country it would serve other purposes.
When we moved to this property, many of the fruit trees were painted white at the bottom. The caretaker said that it was to:
1: keep the sun from splitting the trunks (we get 100's here and little to no humidity)
2. prevent the woodpeckers from drilling holes in the trunk base (the walnut tree is riddled with holes and has no paint)
3. help to prevent rotting due to sprinklers hitting the trunk (we've got them on multiple drips now)
When done properly it isn't paint but whitewash. It was to protect the trunk from sun scald. It also helped repel insects that climb up a tree from the ground. Many insects are repelled by the lime in the whitewash. All the orchards used to do it but now they rely on insecticides.
My grandparents used to paint the trunks of the big maples in their yard about 2' up from the bottom. They haven't done it for years though. When I was a kid, I just assumed they liked the way it looked. Never knew it served a purpose!