Nitrous oxide (formula N20) is a volatile gas discovered by the English clergyman and scientist Joseph Priestley in 1793 (Priestley was certainly a bit of a gas man because he also discovered oxygen, carbon monoxide, carbon dioxide, ammonia, and sulphur dioxide).
Priestley made his nitrous oxide by heating ammonium nitrate in the presence of iron filings, and then passing the nitric oxide (NO) that came off through water:
2NO + H2O + Fe → N2O + Fe(OH)2
Humphry Davy, from the Pneumatic Institute in Bristol, England, then began to experiment with the physiological properties of the gas, and visitors to the institute were given nitrous oxide to breathe. Their reactions and his own experiments led Davy to coin the term 'laughing gas', and he also noticed that the gas had anaesthetic properties. "As nitrous oxide in its extensive operation appears capable of destroying physical pain, it may probably be used with advantage during surgical operations in which no great effusion of blood takes place".
However, for 40 years or so after Davy made this observation, most N2O was used for recreational purposes, including at public shows and carnivals; members of the public would pay a small price to inhale a minute's worth of the gas. It wasn't until the mid 1800's that doctors and dentists began to re-explore the pain-killing potential of nitrous oxide.
As is usually the case with a medical breakthrough, it took an accident to help a local dentist to make the intellectual leap that was to catapult nitrous oxide into the domain of medicine. Horace Wells watched as one of the volunteers breathing the gas, a man named Samuel Cooley, staggered into some nearby benches and injured his leg.
But what intrigued Wells was that Cooley man remained unaware of his injury until the effects of the gas wore off. Realising that N2O might possess painkilling qualities Wells approached the deomstrator, a medical school dropout called Gardner Quincy Colton, and invited him to participate in an experiment the next day.
Colton agreed and subsequently administered nitrous oxide to Dr. Wells whilst another dentist extracted one of Wells' teeth! Wells experienced no pain during the procedure, and the birth of N2O as a dental and medical painkiller had arrived.
That's the history of nitrous oxide. Since that time it's been embraced as a safe agent that can be used for pain relief (such as during childbirth and dental procedures) and in general anaesthesia.
On its own it's not a sufficiently potent anaesthetic to induce (i.e. cause) anaesthesia, but once a patient is "under", it's a very good gaseous agent for anaesthetic "maintenance".
In this respect, N2O isn't that unusual since most volatile gases can behave as anaesthetics with intoxicating effects; they differ only in their potency (i.e. how much of them is needed to have an effect). Volatiles with this propery includes the butane you squirt into your cigarette lighter, and even petrol vapours. In fact this latter example has been a serious problem in parts of Australia where members of some Aboriginal communities have been sniffing petrol. This has resulted in BP (British Petroleum) recently producing a blend of unleaded for the Australian market that is less good for sniffing.
No one knows exactly how general anaesthetics work, but the fact that they are usually organic, lipid-loving chemicals suggests that they probably alter nerve cell function by dissolving in the oily cell membrane and affecting the behaviour of membrane pores or channels which control the excitability of the cell.
Alcohol probably works similarly (as someone has already suggested) and there is now evidence that alcohol specifically renders cells more sensitive to one of the brain's inhibitory nerve transmitters called GABA. This means that cells become less responsive in the presence of alcohol, which is why booze is a CNS depressant.
As an aside, it's not just animals that can benefit from the effects of N2O. Cars receive a boost in performance when a burst of "nitro" is injected into the cylinder during combustion. The heat of the burning fuel causes the nitrous oxide to decompose to nitrogen and oxygen: 2N2O → 2N2 + O2
So 2 molecules of gas turn into 3 molecules of gas, which increases the volume of products inside the cylinder, boosting performance. So a bit like Viagra really, although that relies initially on the effects of nitric oxide (NO), rather than nitrous!