Sam, it appears, is the sole inhabitant of a space station on the moon about 20 years in the future set up by a company called Lunar Industries for the purpose of mining Helium-3. Let's just stop there a minute since this is the only real science oriented aspect of the film. Why go through all that trouble to mine an isotope of Helium? I credit this film with actually prompting me to research this since it is not actually explored in great detail in the film. It turns out that H-3 can be used as an energy source in a fusion reactor. "So what?", you say, "I though fusion took too much energy to get started for it to be worth the trouble". And so it is with H-3, however, it has at least two desirable properties. It is a clean nuclear fuel, which means it does not produce toxic waste that must be disposed of (or at least a great deal less of it). It can also spontaneously generate electricity from the fusion reaction because of the release of a charged proton, in addition to the usual heat energy to make steam to run a generator. Apparently, a small amount can go quite a long way. I don't know all the details but the point is that people have seriously looked into this as a viable technology. There is one major problem, however, which is that H-3 is a very rare isotope, and producing it artificially takes too much energy to be useful. And this brings us back to the moon, which has been found to be relatively rich in H-3, especially on the dark side, which is where Lunar Industries has set up their mining operation. At least someone did their homework, except for the fact that the amount of H-3 that would be required to operate even a major city would require several tons of the stuff to be transported back each year, and it's not even clear it could be mined in that quantity. Still, it is an interesting possibility, one that has a well written entry about it on Wikipedia.
So how does one man run an entire mining operation? Well, he doesn't. Most of the station is managed by GERTY the super computer and a fleet of automated harvester mobiles. Sam's main job is to perform maintenance and collect canisters of H-3 from the mobiles to send via launch capsule back to earth. We start at the end of his 3-year term where he is eagerly awaiting his trip home, and then something goes terribly wrong. The rest of the film involves a crazy set of disconnected events that have both Sam and the viewer trying to figure out what is going on, which turns out to be a huge ruse partly foisted on him by GERTY. I don't want to spoil this one too much here because half the fun is in the mystery, and it ends with some nicely heroic acts by both Sam and his computer companion.