We learn things so we can put them to use in our lives and we gain knowledge from our lives' experiences too.
Gaining knowledge is essential.But any knowledge is deemed more benefiting and useful only if it can be put to use. For example you get people studying religion and then working opposite to their learning which meant their knowledge didn't really avail them in anyway. On the other hand when you study of a subject and then you put it to use or teach it to another that's when your knowledge, combined with your actions will actually come to use.
And as for experiences, then yes we should always take a lesson from our various contacts and exposures, be they pleasant or not. That way nothing we ever go through will be in vain.