Generally, the term social security describes a program that uses public funds to provide a degree of economic security for the public. The specific social security discussed here is the United States government program established in 1935 that provides old age, disability, and survivors insurance, as well as supplemental security income, an income for elderly or disabled people.
In the United States, employers and employees are required to pay Social Security taxes. The money raised from these taxes primarily goes to providing benefits for those who have reached retirement age or are otherwise currently eligible. In this way, today's workers provide funds for the people drawing benefits today, and when today's workers retire, the workers of that time will (at least theoretically) provide the funds. You receive Social Security benefits based on the amount of Social Security taxes you have paid, which, up to a certain maximum amount, is based on your income. People who have had greater incomes tend to get greater Social Security benefits. But Social Security also pays a disproportionate amount to people earning low incomes. They need the money more, and a dollar they pay in Social Security taxes provides them higher benefits than a dollar paid by a high-roller. In this way, Social Security in principle provides for those in need.
Social Security reform is in the news pretty consistently. This is beyond the scope of our discussion here but you can learn more about Social Security reform at the Social Security Reform Center. See also How does the Social Security system work?.
The original and essential purpose of SSNs is to keep track of the money you put into the Social Security program so that you can get the benefits you're entitled to. The government needs lifelong, unique identity numbers to keep track of people's payments throughout an entire working life, no matter how often we move or change occupations or even change our names.