Bhagavad Gita

ಯಂ ಹಿ ನ ವ್ಯಥಯಂತ್ಯೇತೇ ಪುರುಷಂ ಪುರುಷರ್ಷಭ ।
ಸಮದುಃಖಸುಖಂ ಧೀರಂ ಸೋSಮೃತತ್ವಾಯ ಕಲ್ಪತೇ ॥೧೫॥
yaṃ hi na vyathayaṃtyete puruṣaṃ puruṣarṣabha |
samaduḥkhasukhaṃ dhīraṃ soSmṛtatvāya kalpate ||15||

Gist of the sloka:
O brave lion among the men, one whose body does not recognize these opposite conditions, he can visualize both happiness and sadness on equal footing. He is a brave person who will reach the place of non-death/mukthi [emancipation].
Lord Krishna continues. One who knows how to treat both sadness and happiness on equal basis reaches the place where rebirth is not an option. It requires someone with great deal of maturity and knowledge to overcome this duality.
The word ‘purusha’ has been used here. The word generally used to refer to as a ‘male’ but real meaning is completely different. One [species] who has fully formed and functional body is known as ‘purusha’ meaning human beings of both sexes.
The real ‘purusha’ actually meaning the Lord himself. It also means one who strives to learn about the Lord, the reasons behind for obtaining the various duality like happiness and sadness.
This purusha body has been given to us so that we can appropriately use it to gain adequate knowledge, wisdom and also help fellow humans and other living species in this world.
Duality of the sensations is a natural phenomenon and given by the Lord according our karmas. One should therefore be mature enough to accept the things as it happens with a firm belief that Lord knows what we need and at what time. Such a brave person is ‘purusha’ and elevates himself towards the Lord.
Lord is like a mother who knows exactly what kind and what level of punishment is to be given to the child to make it correct itself and grow up being a better person. Mother would never exceed her punishment, knowing fully the capability of the child.
Sadness gives us real lesson as it teaches us things which we can never learn from happiness. Lord therefore gives us lessons by giving us difficulties. It shows his immense kindness. Such knowledge gives us the insight to Lord and makes us more mature. One who has learnt such lessons and has obtained knowledge, would no longer need to take birth again and again but rather reaches the place of immortality.