It is worth understanding the Government Pension Fund of Norway as an example of what some countries invest in with their “social security” equivalents. Here is an excerpt from the WikiPedia article to give you the gist of what is in the article.
Norway has experienced economic surpluses since the development of its hydrocarbon resources in the 70s. This reality, coupled with the desire to mitigate volatility stemming from fluctuating oil prices, motivated the creation of Norway’s Oil Fund, now the Government Pension Fund-Global (GPF-G). The instability of oil prices has been of constant concern for oil-dependent countries since the start of the oil boom, but especially so in the decades following the first oil shocks in the 1970s. As the real GDP of oil-exporting states is linked with the price of oil, it has been a goal of these exporters to stabilize oil consumption patterns, and a host of these exporting states singled out sovereign wealth funds as an effective policy tool for achieving this outcome. The adoption of the GPF-G has been in line global economic trends, especially investment patterns. International investment has increased at a significantly higher pace than either global GDP or global trade of goods and services, increasing by 175% over a period at which the former two metrics increased by 53% and 93% respectively.