In this paper a folding wing based on gear meshing deformation mechanism is developed, focusing on structural analysis and further optimization of the folding wing. Compared with existing folding wing concepts, the deformation mode of this wing is easier to manufacture and implement in engineering. A dynamic contact finite element model of gear meshing is established in ABAQUS, achieving the transmission of motion. The meshing simulation on the gear pair and dynamic strength analysis on the gear mechanism is conducted to obtain stress analysis. The results shows that the mechanism meets the strength requirements. Further dynamic numerical simulations are conducted on the outboard wing to determine the hazardous area of the load, indicating that the folding wing meets the strength requirements. At the same time, the analysis is conducted on the displacement at the tip of the outboard wing, indicating that the folding motion is relatively gentle. Finally, based on the stress analysis results, a weight reduction topology design is carried out for the spoke area of the gear and the rib structure of the folding wing using the variable density method. While ensuring strength, the optimal distribution of materials is sought by using as little material as possible, and the model is reconstructed according to the optimization results. The optimization results show that the weight reduction effect is significant.