What is the function of ECS in airplane?
The ECS system is the Environmental Control System.  It is the system that handles pressurization and thermal control of the aircraft. The FAA has a nice handbook on it here. There is some more information on how it works on the new 747-8 here that may be of interest.