Note: In 2016, Apollo 7 astronaut Walter Cunningham spoke with Phil Edwards of Vox and denied that the crew ever flew with ice cream. As Cunningham told Edwards, "We didn't have any of that." The ice cream story, it turns out, was a widely accepted tall tale spread by the press. This post has been updated to reflect that.
Of the many specialty items made for space travel, food was obviously a top priority. NASA commissioned several different companies to come up with freeze-dried snacks that the men could nosh on while in orbit, and the Whirlpool Corporation’s contribution was Neapolitan ice cream in a pouch. Coconut fat, sugar, milk solids, and other ingredients were freeze-dried, ground, and compressed into tasty cubes that were then coated with a layer of gelatin.
Though the press reported the Apollo 7 crew took some with them during their 11-day orbit in 1968, "astronaut ice cream" never actually went into space.
By 1972 technology had improved to the point that astronauts aboard Skylab were able to enjoy real ice cream, and today the main consumers of astronaut ice cream are backpackers, hikers, and survivalists.