An endotracheal tube is placed when:
A patient is unable to breathe on their own
It is necessary to sedate and "rest" someone who is very ill
Someone's airway needs to be protected (i.e., there is an obstruction or risk of one)
Endotracheal intubation is often used during surgery and in a variety of emergency situations. The tube maintains the airway so that air can pass into and out of the lungs.
Surgery
Endotracheal intubation is commonly used during surgery. General anesthesia is commonly used for surgery to make the patient unconscious during the procedure. With it, the muscles of the body are temporarily paralyzed.
This includes the diaphragm, a dome-shaped muscle that plays an important role in breathing. Placing an endotracheal tube makes up for this, as it allows the ventilator to do the work of breathing while you're under anesthesia.
After surgery on the chest, such as lung cancer surgery or heart surgery, an endotracheal tube connected to a ventilator may be left in place to help with breathing after surgery. In this case, a person may be "weaned" from the ventilator, or slowly taken off of it, at some point during recovery.