It was narrated from Abu Hurairah that the Messenger of Allah ﷺ said: "Whoever obeys me, obeys Allah, And whoever disobeys me, disobeys Allah. Whoever obeys the ruler, obeys me, and whoever disobeys the ruler, disobeys me".
The Prophet Muhammad was sent by God as a messenger with a mission to spread His message throughout humanity. He taught us how to live according to Islamic principles and values so that we may achieve success in this world and hereafter. He also taught us about respecting those in authority over us such as our parents, teachers, leaders etc., because they have been appointed by God Himself for our benefit. Therefore it is important for us to obey them out of respect for their position but also out of respect for God who has appointed them over us.