A major thing to consider when deciding whether to invest or pay off debt is cash flow. Specifically, how each choice affects your cash flow, and how your cash flow is affected by various events.
Simply enough, your cash flow is the amount of money that passes through your finances during a given period (often a month or a year). Some of this is necessary payments, like staying current on loans, rent, etc., while other parts are not necessary, such as eating out.
For example, you currently have $5,500 debt at 3% and another $2,500 at 5%. This means that every month, your cashflow effect of these loans is ($5,500 * 3% / 12) + ($2,500 * 5% / 12) = $24 interest (before any applicable tax effects), plus any required payments toward the principal which you don't state. To have the $8,000 paid off in 30 years, you'd be paying another $33 toward the principal, for a total of about $60 per month before tax effects in your case.
If you take the full $7,000 you have available and use it to pay off the debt starting with the higher-interest loan, then your situation changes such that you now:
- have $0 in the bank (but see below)
- have no outstanding debt at 5%
- have $1,000 in debt at 3%
Assuming that the repayment timeline remains the same, the cashflow effect of the above becomes $1,000 * 3% / 12 = $2.50/month interest plus $2.78/month toward the principal, again before tax effects. In one fell swoop, you just reduced your monthly payment from $60 to $5.25. Per year, this means $720 to $63, so on the $7,000 "invested" in repayment you get $657 in return every year for a 9.4% annual return on investment. It will take you about 11 years to use only this money to save another $7,000, as opposed to the 30 years original repayment schedule.
If the extra payment goes toward knocking time off the existing repayment schedule but keeping the amount paid toward the principal per month the same, you are now paying $33 toward the principal plus $2.50 interest against the $1,000 loan, which means by paying $35.50/month you will be debt free in 30 months: two and a half years, instead of 30 years, an effective 92% reduction in repayment time. You immediately have another about $25/month in your budget, and in two and a half years you will have $60 per month that you wouldn't have if you stuck with the original repayment schedule. If instead the total amount paid remains the same, you are then paying about $57.50/month toward the principal and will be debt free in less than a year and a half.
Not too shabby, if you ask me. Also, don't forget that this is a known, guaranteed return in that you know what you would be paying in interest if you didn't do this, and you know what you will be paying in interest if you do this. Even if the interest rate is variable, you can calculate this to a reasonable degree of certainty. The difference between those two is your return on investment.
Compare this to the fact that while an investment in the S&P might have similar returns over long periods of time, the stock market is much more volatile in the shorter term (as the past two decades have so eloquently demonstrated). It doesn't do you much good if an investment returns 10% per year over 30 years, if when you need the money it's down 30% because you bought at a local peak and have held the investment for only a year.
Also consider if you go back to school, are you going to feel better about a $5.25/month payment or a $60/month payment? (Even if the payments on old debt are deferred while you are studying, you will still have to pay the money, and it will likely be accruing interest in the meantime.)
Now, I really don't advocate emptying your savings account entirely the way I did in the example above. Stuff happens all the time, and some stuff that happens costs money. Instead, you should be keeping some of that money easily available in a liquid, non-volatile form (which basically means a savings account without withdrawal penalties or a money market fund, not the stock market). How much depends on your necessary expenses; a buffer of three months' worth of expenses is an often recommended starting point for an emergency fund. The above should however help you evaluate how much to keep, how much to invest and how much to use to pay off loans early, respectively.