Hydrocarbons contain massive quantities of easily liberated energy and large quantities of easily liberated hydrogen.
Which are then easily and economically converted to ammonia to power the largest single form of fertilizer used in the world - nitrogen fertilizer, in the form of ammonium nitrate and equivalents. [https://en.m.wikipedia.org/wiki/Haber_process]
10’s of millions of tons/year are produced right now.
That process alone is responsible for likely at least 50% of the human population increase since it was invented, literally billions of people.
It is much harder to get there with any other form of energy, albeit not impossible.
It's harder, but if one looks at the externalities from fossil fuel consumption, it's actually cheaper to use renewable energy now.
Hydrogen for ammonia production is very cheaply storable (underground, like natural gas is stored) and would provide a large dispatchable demand to ease integration of renewables into the economy, smoothing over long timescale intermittency.
In any case, because the energy used for agriculture is so relatively small, if the economy as a whole can get off fossil fuels, agriculture certainly can as well.