It was narrated from Abu Hurairah that the Messenger of Allah (ﷺ) said:
“A legal punishment that is carried out in the land is better for the people of that land than if it were to rain for forty days.”
Abu Hurairah said:
"The Messenger of Allah (ﷺ) said: 'A Hadd punishment that is carried out on earth is better for the people of earth than if it were to rain for thirty mornings."' (Daif)