Apple borer beetles lay their eggs in the base of the trees, mostly apples and crab-apples but occasionally also pears. Once hatched, the larvae (like maggots) grow inside the trunk of the tree, eating the living interior of the bark for 2-3 years before hatching into an adult. This boring in the bark can kill a tree.
Check the base of the tree for damage each spring or early summer. If you find holes or frass (orangish sawdust - larvae poop) remove dead bark and try to crush the borers with a piece of wire shoved into the hole. Crushing them is effective - there are usually only one or a couple in each tree if you check them yearly, and there won't be more unless another adult lays more eggs. Undiluted neem oil spray rubbed onto the trunk may also work.