Soil biochar is a kind of organic matter rich in carbon, which is of great significance in soil fertility improvement, fertilizer type innovation and greenhouse gas emission reduction. In this paper, Mg-modified biochar was prepared by thermal cracking using rice straw and corn straw as raw materials. The Mg-modified biochar and unmodified biochar were fully mixed with prepared soil samples at the addition amounts of 0.5% (w/w), 1% (w/w) and 2% (w/w), respectively, and then simulated indoor soil cultivation experiments were carried out. The effects of magnesium ion-modified biochar and non-modified biochar on soil chemical properties and the effects of different amounts of biochar on soil properties were studied. The results showed that the yield of Mg-modified biochar from rice straw and corn straw, prepared by pyrolysis, was 65%, and the ash content was large. The pH of MG-modified corn stalk biochar (MCBC) is weakly basic (8.55), while the pH of MG-modified rice stalk biochar (MRBC) is basic (10.1), and their internal structures are slightly different. After the application of biochar prepared from rice straw and maize stover, soil indicators were determined. Compared to the control, the chemical properties of the treated soil samples were significantly improved, with an increase in soil pH, an increase in the content of effective nutrients, such as fast-acting potassium, fast-acting phosphorus and alkaline dissolved nitrogen, and an increase in the content of the total phosphorus and total nitrogen, as well as an increase in the content of organic matter. The Mg-modified biochar was generally superior to the unmodified biochar in improving soil fertility, at the same addition level. It was also found that the rice-straw biochar performed better than the corn-stover biochar and had a more obvious effect on soil improvement in terms of fast-acting potassium, ammonium nitrogen, nitrate nitrogen, total phosphorus and total nitrogen contents.