The selective laser melting (SLM) forming process of 24CrNiMo alloy steel was optimized by orthogonal experiment. The density and microstructure of the sample were analyzed, and the optimized process parameters were as follows: laser power 300 W, scanning speed 530 mm/s. The 24CrNiMo alloy steel samples were prepared with optimized parameters. The relationship between residual stress and thermal fatigue and the effect of stress-relieving annealing (SR) on residual stress were analyzed. The density of the sample was found to increase at first and then to decrease with the increase of laser power and then to decrease with the increase of scanning speed. Increasing the laser power and scanning speed widened and deepened the weld. Under the optimized process window, the formability of 24CrNiMo alloy steel samples was improved significantly. The residual stress distribution was tensile stress, which had a negative effect on the thermal fatigue properties of the sample. After SR, the residual stress changed to compressive stress, which had a positive effect on the thermal fatigue properties of the samples. Compared with the deposited state, the thermal fatigue cracks were significantly shortened after SR, which was able to further promote the improvement of thermal fatigue performance. The gradient residual stress test showed that the gradient residual stress in the edge region and the central region of the deposited sample had the same trend, and decreased gradually from the surface layer to the base layer.