People marry to get company that they would not get if they were single. Nobody wants to return to an empty home, which is what happens if you do not marry. Isolation can be killing. Studies have shown that isolation can be harmful to health as heavy smoking or drinking.
It is only in the movies that bachelors look young and carefree. If you see men who are single, after the age of 28 or so, you will find that they look older and more worn out than married persons of the same age. Scores of studies done in North America and Western Europe shows that married people enjoy better health than singles. They also live longer.
Well, for one, you're making a rather broad assumption that people in general get married rather than just live with someone. Recent statistics here in the US show that more people than ever are not married when compared to people who are. This doesn't mean that all of these people live in single apartments or lonely in big houses. Many people chose not to get married, while others simply cannot.
People who live together might choose to do so because of previous marriages that may or may not have ended badly, and they choose not to go through that again. Others may choose not to get married, but decide on cohabitation with their partner because of divorce agreements from a previous marriage, such as financial or child custody based. Others still may just dislike the traditional role of marriage in their shared lives or hesitate because of the level of commitment involved.
There are also people who cannot marry, whether due to religious or social constraints or even legal reasons, such as still being married to another, even though that person may no longer be in his or her life, or because state or federal laws prohibit their legal union. This was evident in some States, especially in the South, up until the Civil Rights Act anti-miscegenation ruling of 1967 when the prohibition of interracial marriages were finally struck down. Today, this type of discrimination in the area of marriage can be seen in the conservative far Right's anti-gay rights movement, which had it's pinnacle in President Bush's Defense Of Marriage Act (DOMA). This movement and DOMA sought to include a an Amendment to the US Constitution defining the legal definition of marriage to be a union that can only exist between one man and one woman. This measure failed to pass, but many individual States have taken up the issue this past election year. This is why many gay men and women cannot partake in marriage, except in Massachusetts, the only State that that currently recognizes gay marriage.
All of the above are reasons why more people are NOT married, compared to the number of people who are.
Some of the reasons people DO get married, instead of cohabitation, include its meaning of (supposedly) lifetime commitment. It is a way to publicly, and sometimes religiously, declare the union that two people already share in their hearts and minds. In a strictly religious context, it is a sacred bonding of two (or more) people in the eyes of their faith and/or their God (not all religions have a central God, though many have ceremonies or traditions about marriage). In a more secular role, marriage plays a legal part in many areas, including shared financial responsibilities, next-of-kin decision making capabilities for medical reasons and taxation purposes.
When marriage first started being used as a formal union among the earliest recorded histories of Western culture, early pre-Hebrew nomadic tribes in Mesopotamia, it was primarily used as a means in which to manage and control wealth and property. As true lineage often times could only be traced through the mother's line, family property, such as livestock and food stores, were attached to the female members of a tribe or family. Men, being the power mongers that we are (ha!), would take wives to gain wealth or trade daughters to share it.
Of course, like all things human, marriage has come quite a long way since the early days and it is only seen in this same light in some extremely restrictive or still-tribal cultures. Marriage has picked up a lot more nuance since then, but still does not hold appeal to everyone.