As long as you identify your self with this body, you will feel miserable. Atman is not the body, sense, or ego. It is due to ignorance that you are affected by these worldly sorrows.
When you dream of something it seems real as long as the dream lasts. Similarly, to a man who always thinks of the senses and the pleasures derived there from, this world seems real.
If good deeds are done with a sense of ego, they only bind you to this world. So to gain knowledge you should work without the least trace of pride.
Pure knowledge is that which kills all desires and attachments. Any work with a particular motive behind it should be given up, it only binds you to the cycle of birth and death. It is harmful for your attaining real knowledge.