It depends on the type of requirement or use case and the devices that you have with you.
In general, edge device is a device that sits closer to hardware but far away from cloud, which brings computation and data storage closer to the location where it is needed, to improve response times and save bandwidth. In scenarios where the latency could be high to send it to cloud and process it, the edge device shall be helpful in doing quick processing / analytics. Edge device brings out part of the activities that were done in cloud computing capabilities to local devices and hence reduce delays, increase processing and reduce security issues etc. Typical use cases are time critical scenarios like notification of key equipment malfunction or for a autonomous car to stop immediately, it is felt that to process immediately by having a node nearby and act upon rather than sending it all the way to cloud and act on it.
However, if there is a use case that the latency or bandwidth usage is not a constraint and there is processing hardware limitation, then it is preferred to send the data to cloud and have it processed. Here, a gateway is a device that collects data from sensors for the purpose of analytics, aggregation and translates to protocol that is required to communicate with cloud. Also, note that the protocols such as HTTP, AMQP, and MQTT are the default protocols that Azure IoT Hub supports for communication over the internet with devices or gateways. Few devices or field gateways might not be able to use one of these default protocols and will require protocol supports and in such cases, you can use a gateway that can enable a protocol wrapper for IoT Hub endpoints by bridging the traffic to and from IoT Hub, hence, avoiding any impact on your IoT implementation. This is where Azure IoT protocol gateway is helpful.
The Azure IoT protocol gateway is a cloud feature or framework for protocol adaptation and is a pass-through component that accepts device connections over a specific protocol and it bridges the traffic to IoT Hub. It is designed for high-scale, bidirectional device communication with IoT Hub.
The main difference is that protocol gateway is a cloud feature so whichever protocol your device uses, it needs to at least be able to send its messages to the cloud for protocol translation. However, the IoT Edge, as the name suggests it is part of edge computing and it sits closer to device. It runs locally and can communicate with devices on the local network before sending information to the cloud. And, of course, IoT Edge enables additional scenarios if you're looking to do other edge computing. Azure IoT Edge can also be used to satisfy any need for an IoT gateway as well, whether it's related to connectivity, identity, or edge analytics. Hence, there are three patterns for using an IoT Edge device as a gateway such as transparent, protocol translation, and identity translation which you can choose as per your deployment use case or requirement. IoT Edge device accomplishes this with the help of IoT Edge runtime .