As he is getting ready for bed, Sam's mother reminds him to sort his socks before going to school the next day. As he falls asleep, he begins to dream about having a machine to do it for him, with moving belts, chutes, and other strange inventions to move differently colored socks into the similarly-colored baskets (which the game plays through). In this game, Pajama Sam is voiced by E.G. Daily.
Source: Wikipedia, "Pajama Sam", available under the CC-BY-SA License.