Drawing anything in Windows ia transitory, unless it is drawn onto the surface of a bitmap or similar that is redrawn when necessary. As a result, if you don't re-draw your rectangle when another app covers it up and then it becomes visible again it will disappear - there really isn't anything you can do about that.
And your app doesn't "own" the desktop, so there is no mechanism for your app to be notified that your rectangle needs re-drawing.
You could do it with a Timer - but that's a messy and nasty kludge - but other than that, you can copy the desktop, create a temporary wallpaper and draw on that so the system "maintains" your drawing for you.
This may help:
c# - Change desktop wallpaper using code in .NET - Stack Overflow[
^]