The organic combination of traditional rule of law culture and Civics education in colleges and universities is a breakthrough to improve the effectiveness of Civics education. Focusing on the Civic and political education that integrates traditional rule of law culture, the article introduces virtual reality technology and differential evolution algorithm to explore the course effect optimization method of Civic and political virtual reality teaching, and obtains the optimal content applied to the corpus through differential evolution algorithm according to the content characteristics of Civic and political education. On this basis, the evaluation index system is constructed to assess the course optimization effect of Civics virtual reality teaching. Example validation shows that the Civics corpus based on differential evolutionary algorithm and the proposed Civics virtual reality teaching method achieve better Civics course optimization effect, with an overall score of 3.833, and have the ability of practical application. Students of different genders and grades show significant differences (P<0.05) in the evaluation results of most of the first-level indicators. The application section of virtual reality technology promotes the teaching effect of traditional rule of law culture into the ideological education of colleges and universities.