Withdrawing from a 401(k) early can help you secure a higher Social Security benefit. Here's the math behind it.