And to piggyback off @Jay Hinrichs, the rates suck, the down payment can be as high as 50%, and the portion of income earned relative to the % of debt is subject to UBIT in most situations.
A $100k house might get you $1000-1200 in rent depending on the area. I can find you two sub $50k houses in Gary that get you $800-1000/m rent but it’s D class stuff which has it’s own issues. But let’s say you find a nice property in a C+/B- area that fits your criteria and you’re all in around $100k getting 1% rent. Realistically, it’s older inventory so maintenance and capex will be on the higher end. Since it’s your 401k (which you’d have to roll to a self directed account and have to be hands off), you need managements. A very realistic bet is going to be right at 50%. It may be higher for a few years but again, those old buildings and C class tenants over time will bring the average return to 50%. I know from experience and tracking my returns on over 3 dozen houses in this type of property (i like numbers and can tel you to the penny what each property made). Anyhow, you’re looking at an average return of $6k which is 6%.
Since your retirement owns the house, you don't benefit from depreciation. Your property does appreciate so that's a perk that increases your IRR but you only realize that when you sell.
So which is better? There’s no right answer. The math is probably similar with RE having potentially a higher return. Both markets will increase and decrease over your 15-30yr timeline. I do tremendously better in RE but it’s way more active. You don’t plop your money in a house and sit back and watch like a mutual fund. Do what you enjoy too.