What was happening in Bavaria that lead to the limitation of ingredients in beer?
Before I start, I'm afraid I won't be able to provide any sources. I'm a beer writer, and have read a lot on the matter. I can only recommend Ron Pattinson's blog (http://barclayperkins.blogspot.cz/) that has plenty on the topic. So, if the mods won't mind, I'll have a go.
There are several misconceptions about the Reiheitsgebot. It was not the first law of its kind; a similar one had been enacted in Munich not too long before, and chances are that equivalent legislation was applicable in other parts of what is today Germany. It didn't have any competence on consumer protection and quality assurance, nor it intended to. If you read the text, you'll see that the penalty for breaking the limitation of ingredients was simply confiscation of the beer, and maybe a fine, IIRC.
At the time it was enacted, the limitation of ingredients served a double purpose. The first one was to reserve the use of wheat and rye to bakers (they were both very popular for brewing at the time), who didn't want to use barley. The second one is taxes. By forcing brewers to use only barley (by then, they were the only ones using hops commercially), the government could have a much better idea of how much beer they were making, and be more effective at collecting taxes (beer was a pretty big business already back then, and important source of tax revenues for cities and regions). The original text also dedicates a whole paragraph to set the prices at which beer could be sold.
The law would be later amended to allow (I think only nobles) to brew wheat beer, but only in summer; and would also become a protectionist tool, and even a political bargaining chip (as a condition to join the unified Germany, Bavaria demanded that their beer law be applicable by all the other members of the federation).
EDIT: Two more things to bear in mind. 1) The law wasn't forced on the brewers. The Bavarian government consulted it with the guilds and they accepted it. 2) The original text did not require the barley be malted. Breweries at the time would by default produce their own malt.