In a diversified portfolio, Treasury bills -- a short-term security backed by the U.S. Treasury Department with a maturity of one year or less -- have been considered an afterthought over the past decade due to low yields. However, as interest rates have climbed, so have Treasury bills, which currently yield in the neighborhood of 4.5% to 5%.

Warren Buffett, the legendary investor and CEO of Berkshire Hathaway (BRK.A -2.04%) (BRK.B -1.96%), holds nearly $95 billion of Berkshire's assets in Treasuries as of Dec. 31, 2022.

Here's a look at how to buy Treasury bills and why the Oracle of Omaha is scooping them up hand over fist.

How do you buy Treasury bills?

Treasury bills are sold at auction directly from the Treasury Department at TreasuryDirect. The bills are sold in $100 increments at four-, eight-, 13-, 17-, 26-, and 52-week intervals.

Bills are sold at a discount, and when the bill matures, the Treasury Department pays the holder $100 for each one. The difference between the sale and maturation prices is the interest rate. For example, if the going interest rate for a four-week bill is 4.5%, then it would cost around $99.65 to purchase, and the Treasury Department would pay you $100 after 28 days.

It's important to note that the interest rate or yield is expressed as an annual rate, not for the holding period. Also, you can hold a bill until it matures or sell it before it matures, meaning it's a very liquid asset. 

An easier way to buy into Treasuries is to purchase an ETF. There are many available to investors, but SPDR Bloomberg 1-3 Month T-Bill ETF (BIL 0.07%) and SPDR Bloomberg 3-12 Month T-Bill ETF (BILS 0.05%) are two of the more popular ones. Investors should expect very little movement in the share price for these ETFs, and their yields are typically slightly lower than if you were to buy Treasury bills directly from the Treasury Department. 

You can also purchase Treasuries from your online broker, but they often require a minimum purchase of $1,000. One benefit of buying T-bills is that if you're investing in a regular taxable account, the interest paid is only subject to federal income taxes, not state or local taxes.

Why does Berkshire Hathaway own so many Treasury bills?

Despite stashing most of Berkshire's cash into Treasuries, Buffett has mixed feelings about the asset class. Buffett has noted in past annual shareholder letters that Treasury bills are Berkshire's "default" position for the company's cash when he can't find anything exciting to invest because of their liquidity and safety.

Buffett also wrote that "over the long term, however, [Treasury bills] are riskier investments -- far riskier investments -- than widely diversified stock portfolios that are bought over time."

To sum up, Buffett, a historically shrewd allocator of cash, will only invest in and acquire companies when he believes the price or valuation is fair. So when he believes the market is overvalued, he will instead park Berkshire's money in Treasuries just as a means to gain small returns for its cash.

Should you buy Treasury bills?

If you need cash or are at retirement age, Treasuries provide an excellent way to insulate your money from the daily volatility of the stock market. 

Regarding risks, Treasury bills are considered much safer than stocks. But as Buffett notes, that safety also limits the upside in the long term. Also, as unlikely as it sounds, if the U.S. government defaults on its debt before Congress can resolve the debt ceiling debate, which could happen as early as this summer, then investors might face delays in getting their money back at maturity.

There's no denying that Treasuries have finally become attractive again as interest rates have skyrocketed. Still, unless you're in retirement or need the cash in the short term, investors with a long time horizon are better off keeping most of their money in the stock market, which has gained an annualized return of roughly 10% since 1970.