Traffic congestion is largely due to the high proportion of solo drivers during peak hours. Ridesharing, in the sense of carpooling, has emerged as a travel mode with the potential to reduce congestion by increasing the average vehicle occupancy rates and reduce the number of vehicles during commuting periods. In this study, we propose a simulation-based optimization framework to explore the potential of subsidizing ridesharing users, drivers, and riders, so as to improve social welfare and reduce congestion. We focus our attention on a realistic case study representative of the morning commute on Sydney's M4 Motorway in Australia. We synthesize a network model and travel demand data from open data sources and use a multinomial logistic model to capture users' preferences across different travel roles, including solo drivers, ridesharing drivers, ridesharing passengers, and a reserve option that does not contribute to congestion on the freeway network. We use a link transmission model to simulate traffic congestion on the freeway network and embed a fixed-point algorithm to equilibrate users' mode choice in the long run within the proposed simulation-based optimization framework. Our numerical results reveal that ridesharing incentives have the potential to improve social welfare and reduce congestion. However, we find that providing too many subsidies to ridesharing users may increase congestion levels and thus be counterproductive from a system performance standpoint. We also investigate the impact of transaction fees to a third-party ridesharing platform on social welfare and traffic congestion. We observe that increasing the transaction fee for ridesharing passengers may help in mitigating congestion effects while improving social welfare in the system.