In the absence of contraindications, metformin is the first choice for oral treatment of type 2 diabetes mellitus.
Side effects
In contrast to most diabetes medications, metformin often leads to modest weight reduction or weight stabilzation. Gastrointestinal side effects are common such as gas, bloating, or diarrhea. But, treatment with metformin alone usually does not cause hypoglycemia (low blood sugar). A rare potentially fatal side effect is called lactic acidosis which can cause severe muscle aches, is increased in diabetes patients with poor kidney function, liver disease, and heart failure.  Also, patients that are about to receive IV contrast material for radiology exams should have metformin held for 2-3 days before and after the procedure.
There is data suggesting a decreased risk for heart disease especially in obese diabetes patients. A randomized trial (1) comparing metformin and glipziide in more than 300 patients with heart disease showed more evidence of cardiovascular benefit of metformin.  In the large diabetes trial UKPDS, during the post-intervention observation period, there was a decreased risk of aggregate diabetes-related endpoint and all-cause-mortality.

Metformin as first line treatment in type 2 diabetes

Patients with newly diagnosed type 2 diabetes who are initially prescribed metformin are less likely to eventually need other medications to control their blood glucose, according to research published in JAMA Internal Medicine. Niteesh Choudhry, MD, of the Harvard Medical School in Boston, and colleagues collected data on 15,516 people starting treatment for type 2 diabetes from July 2009 through June 2013. The average follow-up time was slightly longer than 1 year.  Of those patients, 57.8% were initially treated with metformin, and about one-quarter began treatment with a sulfonylurea. Just 6% were started with a thiazolidinedione and 13% with a dipeptidyl peptidase 4 inhibitor (DPP-4) inhibitor. Around 40% of people taking a sulfonylurea, a thiazolidinedione or a DPP-4 inhibitor added a second drug to their diabetes treatment regimen during the study, according to the researchers. However, just 25% of those on metformin added an additional oral medication during the study period. In addition, 5% of those started on metformin later added insulin to their treatment, according to the study. About 9% of those who started on a sulfonylurea, 6% of those who started on a DPP-4 inhibitor and 6% of those who started on thiazolidinediones, also took insulin. many patients are being started on other drugs, but this study indicates that treatment should start with metformin.
This study supports the predominant practice, which is that most people are started on metformin.

How does it work?

The major effect is to decrease liver glucose output by inhibiting gluconeogenesis. In addition, metformin increases insulin-mediated glucose utilization in muscle and liver, particularly after meals, and has an anti-fat effect that lowers serum free fatty acid concentrations, thereby reducing substrate availability for gluconeogenesis. As a result of the improvement in glycemic control, serum insulin concentrations decline slightly. Metformin has also been shown to decrease food intake and body weight. The cellular target are not completely understood

UPDATED 1-21-2015

1. Diabetes Care. 2013 May;36(5):1304-11. Epub 2012 Dec 10.Effects of metformin versus glipizide on cardiovascular outcomes in patients with type 2 diabetes and coronary artery disease.
2. Lancet. 1998;352(9131):854   Effect of intensive blood-glucose control with metformin on complications in overweight patients with type 2 diabetes (UKPDS 34). UK Prospective Diabetes Study (UKPDS) Group.