Congress requires the US Treasury to invest Social Security income in securities guaranteed as to both principal and interest by the federal government. The Treasury issues special issue securities specifically for Social Security as it does for US Treasury bonds.
When the US Treasury creates the bonds, it sends payroll taxes collected from American workers into the General Fund. The federal government uses the funds in the general fund to pay for government expenditures- this is how presidents have borrowed from Social Security over the years.
When the Treasury needs to pay for benefits, it uses the General Fund to redeem the special-issue bonds, plus the corresponding interest. The principal amount of the special issues redeemed and the interest income are enough to pay the required cost.