As commentators have said, this is a very common idea in mythology and fantasy fiction. It is not mentioned in the first D&D book about deities, Gods, Demi-gods and Heroes, but it is included in Deities and Demigods, published in 1980:
It is possible to imagine a campaign where all the gods in this book — and perhaps more — are co-existent. This would require a truly vast world, one large enough to contain all of the worshipers necessary to sustain such a multiplicity of gods! (page 5)
The source of a deity's godheads is in some way connected to his or her earthly worshipers, though in what manner the gods derive this power is a mystery totally beyond mortal (or immortal) comprehension. However, it is true that a god's power often increases or decreases as the number of his worshipers varies. (page 8)
This clearly assumes that the idea is true for game purposes, and that it's sufficiently well known that a complete explanation is not required.