In the Sunnah there is an indication of every good and restraint from every evil

Once Salman (may Allah be pleased with him) was told: “Did your prophet teach you everything and even how to relieve themselves” Salman replied: “Yes, of course!”
(Muslim, 262)

Allah Almighty said: “He (the Prophet Muhammad) will declare good and forbidden evil” (surah al-A’raf, 157-ayat).

The Messenger of Allah ﷺ said: “Verily, any sent prophet pointed out to his people the good that he knew for them, and warned them against the evil that he knew about”
(Muslim, 1844).

Sheikh Ibn ‘Utaymin (may Allah have mercy on him) said: “Everything that the Almighty and Great Allah has legalized on the lips of His Prophet ﷺ contains benefits. Of the legalized, there is such a benefit that is obvious to each person and such that will manifest itself over time for him ”
see:“ al-Kaua’idu al-fiqhiyya ”, p. 25

Also, the Sheikh (may Allah have mercy on him) said: “Thus, benefit and harm are determined when they return them to the Quran and Sunnah. But they do not define them with the help of opinion, imagination and fantasy. We know that no matter what Allah Almighty commanded, it necessarily contains benefits, and whatever He
forbids, there is always harm in it ” (see:“ al-Kaua’idu al-fiqhiya ”, p. 56).

Sheikh Suleiman al-Ruheili (may Allah bless him) said: “We should also know that if Allah commands us to do something, then it is beneficial for us. By Allah, besides Whom there is no true deity worthy of worship, letting go of the beard will sooner or later benefit us. Regardless of whether we know this benefit or not, we must be sure that everything that Allah has ordered us contains benefits for us.

Indeed, Allah has forbidden us prohibitions because He does not love and hates them, because in committing them there is evil and harm for us, and in leaving them there is good for us! “
(see: “Dawabit ar-riba” p. 105-106).