This paper introduces and examines a nonlinear mathematical model aimed to elucidate the interplay among soil fertility, earthworm population, and inorganic fertilizers concerning agricultural crop productivity. Within the modeling framework, we assume logistic growth of crops, influenced by soil fertility, earthworm population, and inorganic fertilizers. The impact of earthworms on crop yield is explored using a Holling type-II functional response. Furthermore, the use of inorganic fertilizers is presumed to adversely affect both soil fertility and earthworm population. Moreover, we hypothesize a direct influence of earthworm population on soil fertility. We carry out conditions for the boundedness of solutions, existence, uniqueness, and both local and global stability of equilibrium points. Numerical simulations are conducted to validate the analytical conditions. Optimal control strategies are employed to minimize the use of inorganic fertilizers in crop field. Graphical comparisons between models, with and without optimal control, reveal that the latter leads to a slight increase in crop production and improvements in both earthworm population and soil fertility.