The irrational use of pesticides has raised a negative influence on the environment and food security. Therefore, it is imperative to comprehend the current status of pesticide residues in the soil for agricultural production and their impact on the ecological environment. The effect of the main pesticides accounted for soil contamination (such as chlorpyrifos, deltamethrin, cypermethrin, and lambda-cyhalothrin) were studied in 115 representative soil samples (collected from a greenhouse and agricultural field, in Shaanxi, China). The avoidance test of earthworms to soil with studied pesticide was studied. Among them, chlorpyrifos has the highest residue concentration in the soil. Distinct geographical areas and types of land usage had different pesticide distributions. The detection rates of deltamethrin in Guanzhong were higher in greenhouses than in fields. The results manifested that the detection rates of chlorpyrifos and cypermethrin in greenhouses were higher in northern and southern Shaanxi. In addition, the concentration levels of pesticides in different soils are as follows: field soil > orchard soil > vegetable soil, and the concentration of chlorpyrifos was much higher in comparison to other pesticides. The results of the earthworm toxicity experiments showed that the soil treatments with the addition of pesticides caused toxic reactions in earthworms as compared to control treatments (without pesticide application). The earthworms exposed to toxic conditions showed morphological changes in their epidermis. Significant avoidance behavior was observed by earthworms, with avoidance rates exceeding 55%. The research results revealed the residual amounts of organophosphorus and pyrethroid pesticides in Shaanxi Province and their effects on the morphology and behavior of soil animals, providing a reference for pesticide application and control in the study area.