Offer your insights or judgment on the input financial query or topic using your financial expertise. Reply as normal question answering

Formula that predicts whether one is better off investing or paying down debt
Old question I know, but I have some thoughts to share. Your title and question say two different things.  "Better off" should mean maximizing your ex-ante utility.  Most of your question seems to describe maximizing your expected return, as do the simulation exercises here.  Those are two different things because risk is implicitly ignored by what you call "the pure mathematical answer."  The expected return on your investments needs to exceed the cost of your debt because interest you pay is risk-free while your investments are risky. To solve this problem, consider the portfolio problem where paying down debt is the risk-free asset and consider the set of optimal solutions.  You will get a capital allocation line between the solution where you put everything into paying down debt and the optimal/tangent portfolio from the set of risky assets.   In order to determine where on that line someone is, you must know their utility function and risk parameters.  You also must know the parameters of the investable universe, which we don't.