A purposeful life remains connected to remembrance of Allah, beneficial knowledge, and upright action. A learner applies knowledge to worship and character; a teacher explains accurately and strives to act on it; a provider earns lawfully and fulfills family obligations. Intention and proper conduct matter throughout.
In وَمَا وَالَاهُ, مَا refers to associated things, and وَالَاهُ conveys following or being connected with it. Thus the phrase extends the exception to works related to remembrance.
Knowledge is more than collecting facts. Understanding, practicing what is learned, and benefiting others are central aims.