The es in the sentence "Es besteht kein Zweifel" is what is known as a dummy subject. According to Hammer's German Grammar, 5e: "es is often used as a 'dummy subject' in initial position in order to permit the 'real' subject to occur later in the sentence. This construction is particularly frequent if the 'real' subject is a noun phrase with an indefinite article or an indefinite quantifier. It gives more emphasis to the 'real' subject. Es may be used in this construction with any verb in German. The verb agrees with the 'real' subject, not with the es." (p.58) Some examples given in Hammer's (the 'dummy' subject is in bold):
Es waren viele Wolken am Himmel. | There were many clouds in the sky.
Viele Wolken waren am Himmel. | Many clouds were in the sky.
Es saß eine alte Frau am Fenster. | There sat an old woman by the window.
Eine alte Frau saß am Fenster. | An old woman sat by the window.
Es liegen zwei Briefe für Sie auf dem Schreibtisch. | There are two letters for you lying on the desk.
Zwei Breife für Sie liegen auf dem Schreibtisch. | Two letters for you are lying on the desk.
So, "Es besteht kein Zweifel" could theoretically be rephrased as "Kein Zweifel besteht", although the latter sounds unidiomatic to me as a main clause, i.e. I would sooner say and expect to hear
"Es besteht kein Zweifel (daran), dass Deutsch eine schwierige Sprache ist."
"Kein Zweifel besteht (daran), dass Deutsch eine schwierige Sprache ist."
although the second sentence does not sound awful to me (native speakers may have a different opinion).
In contrast, in the fixed phrase "es gibt", es is the 'real' subject of the verb geben, which is why this phrase in German is always "es gibt" (i.e. unless you use it in a compound construction such as with a modal verb, but then the modal would agree with es, e.g. Hier soll es mehr Naturwald geben.). Consequently, whatever "it gives" (read: "there is" or "there are") is the direct (accusative) object, e.g. Es gibt keinen Zweifel, Es gibt einen Fehler im Text, etc.
NB that dummy subjects also exist in English (https://dictionary.cambridge.org/grammar/british-grammar/dummy-subjects), but the matter's less complicated because we don't have a prominent case system.