Why does the inverted yield curve occur with US Treasury securities? I have always thought that US securities were considered nearly risk free as the government will almost always pay them back. So why is it the case that investors currently view short term securities as more risky than long term ones?
In general a longer maturity rate is practically speaking as equally profitable as a series of short maturity rates compounded. So for example, investing for 1 year thrice is as equally profitable as investing for 3 years. Investing for 6 months 16 times is as equally profitable as investing for 8 years. There is no certainty of equality and you can make money if you guess correctly. If there are many guessers then near equality will be realized. 

The U.S. Treasury short maturity yield is higher than some of the long maturity yields (today), not because the short maturity investments are riskier. It is because the very short term rate (overnight) set by the Federal Reserve is high enough that the 3 month rate is higher than the 10 year rate. In other words, the expected mean rate for the next 3 months is higher than the expected mean for the next 10 years. Sometime in the future there might be a recession and the Federal Reserve might want to lower the overnight rate to help the economy. Sometime in the future the Federal Reserve might increase the overnight rate to reduce inflation. Both these considerations form expectations. 

In addition to overnight rate setting, the Federal Reserve has engaged in other activity that influences Treasury rates. The Federal Reserve increased its holdings of Treasury bonds in the period from 2008 to 2014. These economists (Gagnon and others) in a paper titled "The Financial Market Effects of the Federal Reserve’s Large-Scale Asset Purchases" estimated that these purchases have been a downward force on long term rates. 

The graph shows that those holdings have been decreasing since early 2018 so there might be reason to think that any downward force on long term rates is now not what it used to be so if we see a rise in those rates there is reason to think of causes that are apart from a change in risk perceptions.



Addendum: @Michael rightly points out that market participants bidding up long term bond prices is another force that lowers long term bond yields.