Granaries of ancient cities stored grains like wheat, barley, millet, maize, rice, and oats. Geographical and climatic factors both influenced the preferred grains. Wheat and barley were common in the Middle East, while rice was the staple food in China. Maize was the primary food source for many early American cultures.
Some grains were favored because they grew well in a given climate, while others were more convenient to harvest, mill, and store. The grains' high dietary value and delicious flavor certainly didn't hurt their widespread adoption, either.
Grain preferences and consumption can be tied to religious and cultural beliefs in some societies. As one example, ancient Egyptians revered barley to the point that it was used in rituals.