There is an interesting story in the Brahma Vaivarta Purana which shows how Indra lost his pride. After defeating Vritra, Indra became the king of the demigods (Devas). This victory created unwanted pride in Indra and to commemorate the victory he asked Vishwakarma, the divine architect, to build a palace.
Vishwakarma designed and built a beautiful palace but Indra was not satisfied and he kept on suggesting improvements. Finally an exhausted Vishwakarma took the help of Vishnu and Shiva.
Vishnu one day came to Indra’s palace in guise of a small boy and said that no former Indra had such a beautiful palace. Indra was amused that the boy knew about former Indras. The boy then told Indra about the cycle of birth and rebirth. While he was explaining this, a group of ants passed by and entered into one of the holes in the palace. The boy laughed and said that the ants were all former Indras.
While this conversation was going on Shiva entered the palace as an old hermit. The hermit shows a cluster of hairs on his chest and says that each time a hair falls one Indra dies and another replaces him.
Indra then realized the futility of luxury and was no longer interested in the palace. He decided to leave the palace forever.
Sage Brihaspati then intervenes and tells Indra that the boy was Lord Vishnu and the old hermit was Shiva and they came to teach him a lesson as he had lost his sense due to pride. Sage Brihaspati then teaches Indra the virtues of both spiritual life and worldly life – he asks him to maintain a balance.