Rocks can help deter pests by preventing them from reaching the plants easily and by reducing habitat for insects in garden beds.