The reasonable and efficient use of the abundant biomass resources in rural areas has not been realized. Therefore, the concept of a combined cooling, heating, and power (CCHP) microgrid system, considering biomass pyrolysis and gasification, has been developed by researchers. A biomass gasification device can fully use biomass resources and can play a role in absorbing wind energy. Meanwhile, in order to minimize the operating cost of each micropower supply unit, as well as the environmental pollution costs, researchers have also established an optimal scheduling model for CCHP microgrids, which uses the sparrow search algorithm. In this paper, we have improved upon the traditional sparrow algorithm to solve the problems of its uneven population distribution, poor global search ability, and the risk of falling into local optima, through the development of the random walk sparrow search algorithm (RSSA). First, a sinusoidal chaotic map is used to generate the early-generation sparrow population with a uniform distribution in space. Second, in this study we add a sharing factor to the discoverer’s optimization process to enhance information sharing and the global research capability among individuals in this field. Finally, a random walk strategy is used to form new participants to improve the algorithm’s skill in locally searching for optimal locations. Taking the CCHP microgrid with grid-connected action as a case study, we concluded that compared with the optimization outcomes of the SSA, the total costs incurred by RSSA in summer and winter were reduced by 2.2% and 3.1%, respectively. Compared with the optimization findings for the chaotic SSA algorithm, the total costs incurred using the RSSA algorithm under typical summer and winter days were reduced by 0.14% and 0.13%, respectively. The productiveness of the RSSA algorithm for solving the CCHP microgrid economic dispatch issues has thus been verified.