We wondered that too. It turns out that it's mostly about the stomach of a cow. Cows are ruminants, which means that they are able to digest grass and forage through fermentation. In order for the micro organisms to survive and do their job, there must be a neutral pH in the rumen. Grain fermentation in the rumen produces acid, which lowers the pH of the rumen. This can cause a host of health issues in the cow, including poor body condition, weight loss, fever, diarrhea, and even liver absesses and death in acute cases.
Read more about feeding corn to cattle here.

When a cow eats grass, as it evolved to do, it fills its rumen with barely chewed grass and then regurgitates it once the rumen is filled up, and further grinds it down. Then it re swallows the cud. In the rumen, micro organisms break down the grass like nonruminants can't, making loads of nutrients available, including:

2 to 4 times more heart healthy omega 3 fatty acids

More unsaturated fats

Less saturated fat

3 to 5 times more conjugated linoleum acid (cla)

Over 400% more vitamins A and E

There are also environmental benefits of feeding cows grass.

According to the Food and Climate Change article on davidsuzuki.org, it takes 5 kgs of grain to produce 1 kg of beef and grain production, processing, and transporting requires a great deal of energy. So much so that Michael Pollan calls the cow a "fossil fuel machine."

Could grazing animals help solve the earth's carbon problem? A 12 year study done by soil scientists of the Agricultural Research Service branch of the USDA found that moderately grazed grassland had more carbon stored in the soil than areas that were untouched.

A great read on the environmental benefits of grassfed beef is
"Cows Save the Planet," by Judith Schwartz. Related Articles

Health Benefits of Conjugated Linoleic Acid
Why Grassfed Animal Products Are Better
Michael Pollan Interview: Modern Meat