NOx emissions are very dangerous. They are responsible for acid rain, Smog, breathing related problems and much more. They are also
responsible for global warming. There are many sources of NOx mainly being burning of fossil fuels in power plants and automobiles.
One interesting thing to be noted here is in a combustion chamber, NOx forms only at elevated temperatures as the reaction is endothermic.
Exhaust gas recirculation (EGR) is primarily used to reduce the NOx emissions. However, it also have other advantages such as prevention of knocking, improving the efficiency of Secective catalytic reduction SCR , Efficiency of SI engines and much more.
EGR as the name suggests, recirculates the exhaust gas produced in an internal combustion engine. When the exhaust gas goes into the combustion chamber via the intake manifold, it contains inert gases like CO2 . This helps in bringing down the temperatures of the combustion chamber as the recirculated exhaust gas takes in as much of heat as possible and as discussed above that production NOx in a combustion chamber is proportional to the chamber temperature, the temperature taken away by the recirculated exhaust gases helps in reducing the NOx emissions. This also reduces the cylinder wall temperatures which in turn reduces engine knocking.

The EGR unit consists of EGR valve (Exhaust manifold), Inter cooler, EGR throttle valve (Intake manifold). The inter cooler is a heat exchanger which is used to cool the gases to the temperatures suitable for supplying the gas to the intake section. Some EGR units also employ a scrubber which is essentially a chamber which filters the exhaust system sending the unwanted gas to the atmosphere keeping the required gases within the circuit. This uses some chemicals to separate these gases.
Since the EGR circuit handles exhaust gases, it is very likely that the valves get clogged by dust, soot and other particles over some usage. Therefore, the valves must be checked and maintained on a regular basis and this are not very expensive. But if not treated, it affects the efficiency so badly mainly due to leaks of gases when not needed due to faulty valve. This makes issues like rough idling (sudden rise and fall of engine rpm at idle conditions caused due to open of valve during idling and making the mixture lean), bad performance, etc.

In gasoline engine, a well maintained EGR system helps in improving the efficiency as it wide opens the throttle during par throttle conditions which considerably reduces pumping losses increasing the efficiency. But EGR should remain closed during idling conditions as discussed and during full throttle conditions as it would reduce the peak power output.
Coming to diesel vehicles, there is no change in efficiency as diesel engines do not have a throttle valve. Here, exhaust gases replace excess oxygen that goes to the engine. It is very much likely that a diesel vehicle employed with an EGR system, do not undergo proper combustion resulting in soot (carbon) particles.Diesel Particulate filter DPFis used to filter out these soot particles. EGR also affects passive regeneration of DPF as NO2 being the primary oxidiser in passive regeneration is reduced by the EGR and active regeneration should be
done frequently.