A famous Islamic Scholar, Mullah Ali Qari rahmatullah alayhi writes in his book named Mirqaat, which is the commentary to Mishkaat, about a person who got saved from the army and people of Firawn that drowned during the time of the Prophet Musa (A.S). (This incident is also mentioned in the side commentary of Abu Dawood.)
This person was the Jester of Firawn and he was retained so he could mock the Prophet Musa (A.S). The Jester used to follow Prophet Musa (A.S) around and ridicule him and make jokes out of what he did. The time came when Firawn and his army were chasing Prophet Musa (A.S) and his people until they got to the edge of the river Nile. There, Prophet Musa (A.S) hit the water with his stick and 12 dry paths opened up through which he and his people got to the other side. Firawn and his army followed and the Jester was also on the scene with his king. No sooner did the enemy reach the middle of the paths, that the high walls of water that were formed whilst creating these paths collapsed in on the disbelievers and drowned them all.
It was later seen that the Jester of Firawn had survived the drowning and so the Prophet Musa (A.S) made supplication towards Allah (S.W.T) saying "Oh Allah, out of all the people that harmed me, that caused me distress, this Jester hurt me the most. He used to mock me in front of the people when I preached and he used to ridicule me. He used to copy my words, copy my speeches, imitate my actions and wear the same clothes as me so that he could make a fool out of me in front of the people. I hated him the most and you let him live?
Allah the Almighty replied "The Lover (Allah) does not punish that person who looks (by means of clothing, beard etc.) like the loved one (His Prophet)". This displays to us how much imitating can have an effect on a persons life. The mockery of the Prophet Musa (A.S) that was done by the Jester, by his dressing up like him and his mimicking him, led to his salvation from Allah's punishment and only because he imitated the Prophet.
Think of the all the good effects that can happen to our afterlife if we imitate the Holy Prophet of Allah and take Muhammad as an example and make him our rolemodel. He was the best of creation and the perfect example of how to lead our lives. There is a hadeeth of the Prophet that "a person will be with whom he loves the most". People tend to copy their idols and those they hold high in their eyes, therefore by copying the clothing that the prophet wore or that which has a close resemblance, this is a manner in which we can show our love for the prophet and be with him on the day of judgement. Like the Prophet said "whoever imitates a group he is from them" meaning that whoever imitates a group will be raised with them on the day of judgement. If we imitate the Prophet , the on the Day of Resurrection we will be raised with him and he will intercede on behalf of us to Allah.