Abu Huraira reported: The Messenger of Allah ﷺ said: Does the man who lifts his head ahead of the Imam (from prostration) not fear that Allah may change his head into the head of an ass?
The lesson here is to always show respect for our elders, leaders, and those who are leading us in prayer. We must remember that Allah is watching us at all times and will punish those who do not show respect for others or act arrogantly towards them. It also teaches us to be humble when we pray so as not to draw attention away from God's presence with our own prideful actions.