The challenge of water scarcity poses a significant environmental challenge for the agricultural sector, jeopardizing the sustainable production of vital crops like wheat. Iranian provinces that produce wheat have varying water resources and climatic conditions. These differences have resulted in distinct economic benefits and environmental risks in wheat production among the provinces. In this study, the water footprint of wheat in each province was calculated from 2000 to 2020, and its environmental costs were deducted from the gross margin. Consequently, the social benefit was considered as the return of the wheat production portfolio in each province to manage the risk of sustainable production. Subsequently, the portfolio theory was employed through quadratic mathematical programming to minimize the social benefit-risk and determine the proportion of wheat cultivation in each province for optimal portfolio and sustainable production. The results showed that the provinces of Khuzestan (21.6%), Fars (17.1%), Hamedan (16.1%), Kurdestan (13.2%), Khorasan Razavi (11.4%), Golestan (11.3%), Qazvin (5%), and Kermanshah (4.3%) are in the optimal portfolio. In the optimal portfolio, a significant share of wheat production was related to the provinces with low risk in production (Khuzestan and Fars). The findings suggest that it is necessary to consider economic risks along with environmental risks to achieve sustainable production in the long run. As a result, the eastern and central provinces (Sistan and Baluchestan, South Khorasan, Semnan, Isfahan, Yazd) with the highest water footprint were removed from the optimal portfolio, and the western provinces with higher gross margin and lower water footprint were replaced with a larger share (Kermanshah, Hamedan, and Kurdistan).