A gateway is basically a device that is used to connect two dissimilar networks.
A gateway operates at the highest layer of network abstraction.
Gateway expands the functionality of routers by performing the data translation and protocol conversion.
Gateway is needed to convert Ethernet traffic from the LAN, to SNA (stands for Systems Network Architecture) traffic on a legacy system. It then routes the SNA traffic to the mainframe. When the mainframe answers, then the reverse process occurs.
Note - SNA (Systems Network Architecture) is a networking standard developed by IBM, used by fine IBM mainframe and AS/400 minicomputers everywhere.
A gateway is actually a node on a network that serves as an entrance to another network.
In homes, the gateway is the ISP that connects the user to the Internet.
In enterprises, the gateway node often acts as a proxy server and a firewall. Here proxy server is a machine that is not actually a server but appears as a server and firewall is a system designed to prevent unauthorized access to or from a private network.
The gateway is also associated with both a router, which use headers and forwarding tables to determine where the packets are sent, and a switch, which provides the actual path for the packet in and out of the gateway.