The themes of this sonnet, and of the two that follow, are both love and infidelity. The thematic question posed by the poet is "How should I react when I am betrayed by my friend?" The person of "youth" mentioned in the poem has begun an affair with the poet's mistress - this relationship is explained further in sonnet 41 - and the poet is reacting to it. Despite the disloyalty, the poet is proclaiming his love for the youth. Love encourages humans to give of themselves, and the poet is encouraging the youth to take all he has. The youth is his friend - although the poet is angry, the love he has allows him to forgive. He encourages the youth to take everything he himself has, but insists that they remain friends.
This sonnet follows the theme of love that echoes throughout them all. Shakespeare explores the meaning of true and lasting love, suggesting through various poems that it is not held back by time or beauty, that is the work of deep friendship and not just attraction. Sonnet 40 shows this by displaying how it can survive betrayal.
This sonnet affirms Shakespeare's love for his friend, at the same time expressing his grievance against the friend. Shakespeare's grievance is due to his friend's misdemeanour in having weaned Shakespeare's mistress away from Shakespeare for his own sexual pleasure. But Shakespeare is willing to forgive his friend if the friend continues to be friendly towards him and if they donot become each other's enemies.