The DOE loan was an attractive low-interest loan. Why would they repay it early? Because the DOE loan had restrictive agreements that prevented Tesla to stay competitive.
From page 44 of their May 10th Quarterly Report SEC Filing:
"Our DOE Loan Facility documents contain customary covenants that include, among others, a requirement that the project be conducted in accordance with the business plan for such project, compliance with all requirements of the ATVM Program, and limitations on our and our subsidiaries’ ability to incur indebtedness, incur liens, make investments or loans, enter into mergers or acquisitions, dispose of assets, pay dividends or make distributions on capital stock, prepay indebtedness, pay management, advisory or similar fees to affiliates, enter into certain affiliate transactions, enter into new lines of business and enter into certain restrictive agreements. These restrictions may limit our ability to operate our business and may cause us to take actions or prevent us from taking actions we believe are necessary from a competitive standpoint or that we otherwise believe are necessary to grow our business. In addition, our DOE Loan Facility also contains a variety of customary financial covenants, including covenants related to current ratio, leverage ratio, interest coverage ratio and fixed charge coverage ratio. We modified certain of these covenants in February 2012, September 2012, and again in March 2013."