At times the cause for a person going off the track is an external one, e.g. joining bad company, whilst at other times it is due to some concealed corruption that he has within his heart, e.g. the evil trait of pride. Shaitaan enjoyed the excellent company of the angels, yet he was rejected due to the concealed corruption that he had within his heart of pride.
The simple explanation of pride is that a person wishes to be distinguished from others. He wants to reveal before others that“I can do this, I have this type of influence, I enjoy this type of wealth and have these privileges which others do not have”etc. It takes a lot of effort and time to rid the heart from this evil trait.