The money that people contribute is a tax that goes into the Social Security trust funds, from which current beneficiaries are paid. Those contributions cannot be refunded to the family when an eligible worker dies before filing for benefits; they were used to pay benefits for others during the worker's life.
Think of it this way: Social Security is not a personal retirement account but something more like insurance. (In fact, the official name for Social Security benefits is Old-Age, Survivors and Disability Insurance.) Throughout their working lives, people pay into a national pool that provides some measure of financial protection for those no longer working due to their age or medical condition. When those workers retire (or become disabled) in turn, their benefits are funded by the younger, healthier workers still paying into the pool.
That protection extends to certain members of a qualifying worker's family, who may be eligible for survivor benefits even if that person passed away before claiming Social Security. These can include a widow or widower, a former spouse, dependent parents, and children if they are below certain ages or disabled.
Keep in mind
For a spouse, the survivor benefit can be up to 100 percent of what the deceased would have been entitled to receive from Social Security, had they lived to claim benefits at full retirement age (66 and 4 months for people born in 1956, 66 and 6 months for those born in 1957). The age is gradually rising to 67 for those born in 1960 or later.