In the current study, a renewable system with two potential wind and solar energies for electricity production, cooling, and heating has been investigated. The proposed system included reverse osmosis, heat pumps, fuel cell subsystems, wind turbines, photovoltaic/thermal panel units, battery storage, and a hydrogen storage tank. Given Iran's high potential for renewable energy, a performance analysis of six cities, Esfahan, Zanjan, Bandar Anzali, Ahvaz, Bandar Abbas, and Tabriz was done to determine where the proposed power plant should be located. Six decision factors were analyzed for system performance: solar panel angle, solar panel count, wind turbine count, cooling capacity, heating capacity, and fuel cell power. The findings demonstrate that the number of solar panels, wind turbines, and fuel cells significantly influences power, fuel consumption, and system costs. Finally, the outcomes were analyzed by the Response surface method to choose the best system that can satisfy the demand for residential units for one year. To evaluate the effectiveness of the suggested method, a 100-unit apartment building with a 196-square-meter floor space was considered. The results also showed that the combination of hydrogen units and battery storage reduced variations in supply and demand and correctly stabilized the stored energy during a drop in output. The suggested system has a life cycle cost of 674278.4$/h and the capacity to generate 225694.8 kWh of surplus power for residential units with a thermal comfort index. According to the optimization results, the system's optimal panel count was 106, the optimal angle was 26°, the optimal fuel cell power was 65.6 kW, the ideal wind turbine count was 24, the ideal heating capacity was 20.2 kW, and the optimal cooling capacity was 48.7 kW.