I look at 3 things, yield, equity/security, and performance. As @Chris Seveney stated, the yield is the yield, regardless of remaining term. I would add that calculation of yield should include servicing overhead, i.e., the monthly payment component of the yield calculation should be reduced by the monthly servicing fee. So the effective yield on loans with small P&I payments will be more negatively impacted by servicing expense.
With regard to remaining term, a long term first position loan that is closer to end of term can provide a greater level of equity/security to the lien holder. Also, with regard to performance, the borrower has a lot of skin in the game after paying the loan down that far and so the borrower is more likely to continue paying.
@Gil Ganz mentioned a concern about ratio of UPB to foreclosure expense. On a loan with sufficient equity, the ratio of UPB to foreclosure cost is immaterial because foreclosure costs become part of the recoverable debt in a foreclosure sale situation.
One benefit that a longer term provides is that invested capital is not returned as fast, but I think that is less important than these other aspects.