To answer this question it's necessary to dispel one common misconception: **Middle-earth is actually an incredibly *high-magic* setting**: just look at all the magic items that the Fellowship are laden-down with, the constant references to spells, the magical realms they pass through, and so forth.

There's further discussion (and evidence) of that [here][1], but for the purposes of this question it's just necessary to first establish that "Middle-earth is low-magic" is quite false, so I'll just give you a quote and refer you to the full article for more information.

>  J.R.R. Tolkien created huge heaping treasures of magic items, piled them up, and set dragons to guard them. He raised entire cities around groups of Elven and Dwarven craftsmen who minted, built, constructed, manufactured, conjured, or otherwise produced factory-style volumes of magical cloaks, lanterns, musical instruments, weapons, armor, and maybe even shoes. You cannot find a story about Middle-earth where Tolkien doesn’t have someone do something magical. He has sleep spells, disease spells, spells of far-sightedness, curses, counter-curses, healing magic, and Elves can run on snow.

So the assertion that "as Middle Earth is a very low-magic setting, gunpowder would not be made obsolete by magic, as magic hardly exists at all" is instantly disproven, because:

 - Middle-earth is actually a very high-magic setting,
 - Gunpowder can easily be made obsolete (and even unnecessary) by magic because,
 - Magic exists around every corner and under every stone.

Despite this it seems valid to still ask "why isn't gunpowder more common", but there needn't be a significant reason for this.  The [ancient Chinese had gunpowder][2], fireworks and blasting devices, but yet it wasn't hugely common there either - it was invented entirely by accident, required specialised alchemical knowledge, handling of volatile and dangerous ingredients, and it's use as a weapon was a later development.

The History Stack Exchange site has a [relevant question and accepted answer about the use of gunpowder in ancient and medieval history][3] that's worth reading in this context.


  [1]: http://middle-earth.xenite.org/2011/10/20/how-rare-was-magic-in-middle-earth-should-gamers-have-lots-of-magic-items/
  [2]: http://www.travelchinaguide.com/intro/focus/inventions.htm
  [3]: http://history.stackexchange.com/a/5669/1553