In this research, analysis of a cogeneration system harnessing solar energy with the purpose of producing electricity and freshwater is carried out. A parabolic trough collector (PTC), a reverse osmosis (RO) desalination system and a steam Rankine cycle are considered as the primary modules of the system. Optimization is conducted on the basis of the Non-Dominated Sorting Genetic Algorithm II (NSGA-II), while the Engineering Equation Solver (EES) is used to cope with the presented thermodynamic model. Sensitivity analysis of different key parameters including pump and turbine efficiencies, pump and turbine inlet pressures, evaporator pinch point and inlet temperature and, finally, solar radiation are calculated. A location with high solar energy potential is selected to explore the feasibility of installing the designed system. The case study results show that the maximum level of freshwater production happens during June and July due to an increased sunlight and ambient temperature. Annual electricity and distilled water production of 260,847.6586 MW and 73,821.34 m3 are calculated, respectively. Furthermore, the optimum results regarding the cost rate and exergy efficiency were found to be 35.26 $/h and 12.02%, respectively.