Ghusl for janaabah is an act of worship first and foremost
Question

                Why is it Sunnah for the one who does ghusl to rub his scalp? Does janaabah cause secretions of the scalp?.
Praise be to Allah.
    The believer should hasten to obey the command of Allah, may 
    He be exalted, and the command of the Messenger (blessings and peace of 
    Allah be upon him), and his obedience to the command should not be dependent 
    on knowing the wisdom behind it. For many of the rulings of Islam we do not 
    know the wisdom behind them, but we are certain that there is great wisdom 
    behind them that Allah intended. The scholars call these rulings “rulings of 
    unknown meaning” or “rulings on kinds of worship”, such as the number of 
    rak‘ahs in prayer. 

    Some of the scholars are of the view that ghusl for janaabah 
    comes under the heading of this type of rulings, the wisdom behind which is 
    not known. 

    As-Suyooti said in al-Ashbaah wa’n-Nazaa’ir (638): 

    With regard to the rulings that have to do with rituals of 
    worship…such as the ruling on minor and major impurity, these rulings have 
    to do with rituals of worship, the wisdom behind which is not known; 
    therefore they cannot be subject to rational thinking. Some of the scholars 
    said: if it were not that they are rulings on rituals, emission of maniy 
    (semen) which is taahir (pure) according to most of the scholars would not 
    necessitate washing the entire body (ghusl), whilst urine and stools, which 
    are naajis (impure) according to scholarly consensus, would not necessitate 
    washing only part of it (wudoo’). 

    Based on that, it cannot be said that washing the head in the 
    case of janaabah is because of secretions in the scalp. Rather we say that 
    washing the head in the case of janaabah is part of the practice of the 
    Prophet (blessings and peace of Allah be upon him), whom Allah commanded us 
    to follow and take as an example. Allah, may He be exalted, says 
    (interpretation of the meaning): 

    “Indeed in the Messenger of Allah (Muhammad SAW) you have 
    a good example to follow for him who hopes in (the Meeting with) Allah and 
    the Last Day and remembers Allah much.” 

    [al-Ahzaab 33:21] 

    “Say (O Muhammad SAW to mankind): ‘If you (really) love 
    Allah then follow me (i.e. accept Islamic Monotheism, follow the Quran and 
    the Sunnah), Allah will love you and forgive you of your sins. And Allah is 
    Oft-Forgiving, Most Merciful.’”

    [Aal ‘Imraan 3:31]. 

    The second type of rulings are those of which the meaning is 
    known and the wisdom behind them is understood, such as the prohibition on 
    khamr (intoxicants), so as to protect the mind, body and wealth, and the 
    prohibition on dead meat and pork, because they are harmful, and so on. 

    Some of the scholars were of the view that the meaning of 
    ghusl for janaabah may be understood on a rational basis; they said: The 
    emission of maniy (semen) affects the body with some measure of weakness, 
    laziness and exhaustion. Ghusl counters that and re-energises the body. 

    Ibn al-Qayyim (may Allah have mercy on him) said in I‘laam 
    al-Muwaqqi‘een, 2/77-78: 

    Ghusl following emission of maniy is one of the most 
    beneficial things for the body, heart and soul, and indeed to every part of 
    the body, which is refreshed by doing ghusl. Ghusl counters the effects of 
    emission of maniy; this is something that is well known from experience. 
    Moreover, becoming junub makes one very tired but ghusl re-energizes one. 
    Hence Abu Dharr said, when he did ghusl for janaabah: It is as if I have 
    thrown a weight from me. 

    To sum up: this is something that everyone who has any common 
    sense will understand and realize that ghusl after janaabah refreshes the 
    body and the heart. As janaabah causes one’s heart and soul to become 
    alienated, doing ghusl takes away that alienation. Prominent doctors have 
    stated that doing ghusl after intercourse restores energy to the body; it is 
    one of the most beneficial things for body and soul, and not doing it is 
    harmful. The testimony of reason and sound human nature is sufficient to 
    show that it is good. And Allah is the source of strength.

    End quote 

    And Allah knows best.