It was narrated that Ibn ‘Umar [radhiyallaahu anhu] said to his freed slave Naafi’: “Do you go and meet people bareheaded?” He said: “No.” He said: “Allaah has more right that you should be modest before Him.” So as Ibn Umar mentioned, the point of covering your head is to respect Allaah. That is its function in Islaam.