In The Name of Allaah, The Most Merciful, The Bestower of Mercy.
Imaam As-Sadi [may Allaah have mercy upon him] said:
As for the meaning of beneficial knowledge and its specification, which is indicated by the Qur’aan and the Sunnah, it is every knowledge that leads to the lofty goals that are sought after and results in beneficial things. There is no difference between what is related to this worldly life or the Afterlife (in this affair). Everything that guides to the (upright) path and promotes (sound) beliefs, morals and deeds is part of (beneficial) knowledge.
Commentary: This above statement requires a clarification that would restrict its generality, and that is the worldly sciences cannot transgress against the knowledge related to the Afterlife, otherwise they would be unpraiseworthy. If a person’s knowledge is limited to worldly knowledge and he has no concern for knowledge related to the afterlife- the knowledge that would earn a person Allaah’s (love, pleasure, approval) and paradise, then there is no doubt that this is dispraised; but if – alongside this worldly knowledge – he learns the knowledge related to the afterlife or learns at least what should be known by necessity in the religion, such as the obligatory duties of Islam, then in such a case this is not unpraiseworthy. And if a person has a righteous intention in his pursuit of this worldly knowledge, such as one who studies medicine – or what is similar – to serve the people and cure their ailments by the Will of Allaah, then this deed would be an act of worship that would earn a person Allaah’s (love, pleasure, approval). Therefore, the worldly sciences are praised if they do not transgress against the knowledge that is related to the afterlife. (1)
Read: The Religion of Islam Embodies Beneficial Contemporary Sciences and Professions: https://salaficentre.com/wp-content/uploads/2021/11/Quranic_Proofs_Pdf_final.pdf
[Ref 1: From 11mins 47secs to 15mins 45secs. https://www.al-badr.net/detail/3KwCnaB5tN paraphrased]