The statement is often quoted as "In a democracy, people get the government they deserve," and often attributed to Alexis de Toqueville ... but it's hard to verify where he said it, and even whether he really did.
However, there is a similar and well-documented quotation by Joseph de Maistre: "Every country has the government it deserves (Toute nation a le gouvernement qu’elle mérite") One of the sources below gives its origin as de Maistre's
Lettres et Opuscules Inédits vol. 1, letter 53, written on 15 August 1811 and published in 1851.
Everybody likes to quote de Toqueville, & not that many ever heard of de Maistre. I suspect de Maistre is the real origin. Of course, it's possible de Toqueville said it, in quoting or paraphrasing de Maistre.
But I doubt that de Toqueville said it, simply because it doesn't sound like him. The tone of the remark is sarcastic or cynical, and de Toqueville's writings weren't like that. It wasn't his style.