Trees in forests can obstruct falling rocks and serve as a natural barrier to reduce the velocity of falling rocks. Recently, there has been growing interest in utilizing forests to safeguard against potential rockfall. Nevertheless, there is a dearth of research regarding the impact of rock size and forest structure on forest preservation against rockfall. This study takes the Jiweishan rock avalanche that occurred in China in June 2009 as an example to discuss the protection mechanism of forests against rockfall in rock avalanche disasters. Three sizes of rockfalls from the Jiweishan rock avalanche were simulated and analyzed with and without forests using Rockyfor3D software. The findings indicate that forests can mitigate the energy impact of falling rocks. Especially in the debris flow area of rock avalanches, the protective effect of trees on small-sized falling rocks is most obvious, reducing the runout distance and damage range of the debris flow. Moreover, the protective effect of forest structures on rockfall risk was explored. It was found that broad-leaved forests had the best protection against falling rocks, followed by coniferous broad-leaved mixed forests, and coniferous forests had the worst protective effect. Furthermore, increasing forest planting density and tree diameter at breast height (DBH) can result in better protection against rockfall. Thus, rational planning of forest species and planting density in areas of rockfall can effectively reduce the threat of rockfall risk. The research ideas in this study can provide a basis for evaluating the mitigation of rockfall hazards by forests and provide a reference for constructing and planning protective forests in rockfall and rock avalanche hazard areas.