The line is spoken by Proteus, a villain in Shakespeare's play The Two Gentlemen of Verona.
The saying occurs in act 3, scene 1 of the text, lines 247-8 of the scene. You can see it in an 1838 edition of Shakespeare translated by Ernst Ortlepp, via Google Books:
This is the corresponding passage in English, using the Folger Library online version of the play:
Cease to lament for that thou canst not help,
And study help for that which thou lament’st.
In context, Proteus counsels Valentine to obey his ordered exile (which Valentine can't help) and leave the city, so that at least he can stay free and send letters to his love, Sylvia (the "help" for the situation, which is better than nothing). It's ostensibly good advice, except that Proteus loves Sylvia too and is trying to get Valentine out of the way.
I find it remarkable the saying circulates in German. The Two Gentlemen of Verona isn't one of Shakespeare's more loved plays, and this quote isn't so widely circulated in English. The English quote doesn't even make my edition of The Oxford Dictionary of Quotations (third edition, 1979), which features 13 other quotations from that play. So this may be a case of the quote or the translation having more cultural relevance in German.