The purpose of meditation is to gain freedom from ignorance, and to be serene in all circumstances, whether those circumstances are good or bad. To meditate is to seek wisdom and serenity within yourself.
Through meditation you detach yourself from all external objects; and this leads to inner serenity. If you are attached to external objects, you are constantly disturbed; but when you are free from attachments, you are at peace. Attachment leads to disturbance because it makes you a slave to the objects of your attachment; when these objects change, you are upset. Those who learn to detach themselves completely from external objects, enjoy complete serenity.
Be vigilant at all times. Attachment constantly reasserts itself. So you must constantly strive for detachment.