The invention provides a method for producing biogas through coupling biodiesel oil byproduct crude glycerine purification and pretreated agriculture and forestry residue fermentation. The method comprises the following steps: adding a methanol solution of phosphoric acid into biodiesel oil byproduct crude glycerine, meanwhile, adding agriculture and forestry residues, carrying out uniform stirring so as to obtain a crude glycerine solution, subjecting the crude glycerine solution to standing, carrying out filter pressing so as to separate out a solid phase, i.e., treated agriculture and forestry residues and a liquid phase, subjecting the treated agriculture and forestry residues to anaerobic fermentation to produce the biogas, subjecting the liquid phase to standing layering so as to obtain an upper layer, i.e., a methanol phase and a lower layer, i.e., a glycerine phase, recycling methanol, neutralizing glycerine until the glycerine is neutral, adsorbing the neutral glycerine solution with activated charcoal, then, filtering the glycerine solution, and subjecting the filtered filter liquor to ion exchange and concentration, thereby obtaining purified glycerine. According to themethod, biodiesel oil crude glycerine purification and agriculture and forestry residue pretreatment are treated in a cooperated manner, available ingredients are effectively recovered from the biodiesel oil byproduct crude glycerine, and thus, the recoverable utilization of resources is achieved, so that the method has good economic and environmental benefits.