One possibility you could do if interest rate is less than a loan is taking a loan to purchase something that would hold value well and is resellable. For example, gold. Unfortunately, gold has very volatile prices, so if for example there is 5% inflation yet 3% interest rate, and if you take the loan for 50 years as a bullet loan, you still can't have a guarantee that you win, since in 50 years gold would appreciate 1.05^50 = 11.467x and loan would increase 1.03^50 = 4.3839x, so the ratio is 2.6158x. That's a typical gold price fluctuation. So if gold price would decrease by a factor of 1/2.6158, in addition to increasing 5% yearly due to inflation, you would be at a loss.
Purchasing real estate isn't better either. The Herengracht index shows that property values can drop by 80%. So you can't have guarantees that taking a loan and purchasing real estate would be a winning move.
A slightly better strategy is to purchase stocks. Stocks are a form of real investment as opposed to nominal investment like bonds. Thus, stocks are inherently inflation protected. Unfortunately, 50% drops in stock market are common and 80% drop happened during the Great Depression. So, if stocks yield 8% on average and your loan has 3% annual interest, you would need 34 years to have a good enough guarantee that your investment is winning. (But of course at 5% inflation perhaps 8% return for stocks is too low, maybe they could return far more.)
Also, do note that your loan may not be 3% forever unless you have fixed interest rate. Usually fixed interest rate is more expensive than variable interest rate. Especially if you want a really long interest rate like one that stays constant for over 30 years, it would be very expensive indeed. Furthermore, inflation won't be at 5% forever. The central banks will successfully reduce it to 2% by increasing interest rates.
So profiting from taking a loan with interest rate lower than inflation is very, very hard indeed.
One thing is certain however. If your options are to take a loan and use it for consumption, or to not take a loan, it's always better to reduce your consumption and not take a loan. Loans should only be used for investments: for example if you pay for a leasing car, it might be a valid investment to buy your own car (or it may not), and also if you live in a rental building, it might be a valid investment to buy your own house (or it may not).