IP media gateways convert phone calls between legacy circuit-switched technologies and modern packet-switched technologies (aka VoIP). You can use gateways to connect legacy phone lines with your Asterisk system, or to connect legacy phone systems with VoIP services and features.
Digium has been in the gateway business since we started manufacturing cards in 2003. From the very beginning, clever people have used Digium cards, Asterisk, and ordinary computer hardware to build VoIP-to-TDM gateways. Just pop a card into a computer, install Linux, DAHDi, and Asterisk, and configure to taste. Not too difficult if you know Asterisk. Unfortunately, this solution has a few drawbacks. One of the biggest down sides of this scenario is the computer. Now, those of us at Digium love computers. In fact, much of the advantage of Asterisk is that it runs on ordinary computers. But, while general-purpose computers are great for some tasks,they tend to make poor appliances. They have moving parts (hard drives and fans)that wear out over time. They also burn up a lot of electricity, much of which is used to spin the hard drives and run the fans.
Gateways are solid state devices without failure-prone moving parts. They are frequently used in cases where the Asterisk server does not have card slots, when Asterisk is run in a virtualized environment or when PSTN circuits needs to connect with multiple Asterisk systems.