I come up with an immediate return of 9.6% by getting rid of the PMI. $187x12 months=Annual PMI is $2244. $40,000x.04=Annual interest is $1600. Total cost of borrowing the $40k is $3844/yr or 9.6%.
As the PMI payment is fixed, the cost of borrowing only gets worse if you pay down the loan incrementally towards $343k. For example, at $363k, the cost of the remaining $20k would be $2244 of PMI + $800 interest / $20,000 needed to eliminate PMI which results in an effective cost of 15.22%, only strengening the case for paying the loan down and eliminating PMI in one swift move..
Paying it down seems like a no brainer, just be aware that you will lose around $1600 in deductible interest, which will probably not be completely off set by a reduction in investment income, especially if the dividends are qualified for special tax treatment. Probably not enough to make a difference in your case. But important to understand, especially as the numbers grow over time.
Your "last dollar" tax rate, also called your marginal tax rate, is the rate that your last dollar of income is taxed. For example, your last dollar of income might be taxed 15% on the federal level, 5% on the state level and 2% on the local level for a combined marginal tax rate of 22%. Good to know when you are making decisions with tax implications.