NASA is ultimately responsible for the introduction of visco-elastic memory foam back in the 1970's. At the time, the issue was that astronauts were subjected to a tremendous amount of g-forces during lift-off. So they needed flight seats that would be able to reduce pressure points, but at the same time still provide enough support.
Visco-elastic foam does just that because it's temperature sensitive. When it's exposed to warmer temperatures, it softens and conforms to the body. In cooler conditions, it becomes more firm. So when the astronauts sit down on a memory foam seat during lift-off, it will contour to their body and reduce pressure points.
Memory foam is the only material that reacts in this manner. If the seats were made out of your everyday foam, it would push back against the body instead of conform. This is how pressure points are created.
Pressures points in this case could cause injury to the astronauts when exposed to the incredibly high g-forces of the flight.
By conforming, the memory foam would act as a shock absorber by distributing the forces over a wider area.
However, NASA ultimately decided not to use memory foam because they were not able to perfect it enough for practical use. Since chemicals are used during the manufacturing process, the smell it emitted would be unhealthy in a small, congested space shuttle.
Anyone who buys a memory foam mattress has to deal with a chemical smell at least initially. Most people won't notice it after a few days or weeks. However, they also have the luxury of airing out the mattress by opening windows and allowing fresh air to come it. Astronauts obviously don't have this luxury, and would be forced to breathe in these chemicals for an extended period of time.
The other issue is that the foam seemed to break down in a very short period of time. It would begin to flake and tear after limited use.
So, NASA decided that enough was enough. A foam manufacturing company called Fagerdala World Foams of Sweden bought the rights to the technology.
They developed their own version of the memory foam with the idea of selling it to the public in the form of a mattress. Initially, it was only used by the medical community to help those who suffer from pain.
Fagerdala then created the Tempur-Pedic mattress that would be sold to the everyday customer. Soon, a number of other manufacturers began creating their own memory foam to sell.