Buy-to-let investors who bought 30 years ago are likely to have outperformed those who invested in the stock market, analysis has revealed.