What is the purpose of a USB port in the cockpit?
Some Flight Management System databases are updated via USB stick and require a USB port. Since navigational databases are updated frequently and require a simple way to make an update, USB (or memory card slots) are generally used to allow for rapid and easy updates without having to remove any panels. In some cases the port may be in the avionics bay however that is usually easily accessed as well. It should be noted that a recent change in regulation now allows pilots to update nav data, this question covers it well. 


  Was it really intended for charging devices like phones? That seems
  naively insecure.


Generally these ports are not for charging but the basic design of a USB port more or less always allows you to charge from it because of the nature of the port. The security on the ports is more about cockpit security. In most cases the security lies in making it difficult to get into the cockpit in the first place. It is often assumed now that if you are in the cockpit you should be there. There is of course many questions this opens up some of which have been answered here or would be good to ask about.  

As iPads become more common in the cockpit for navigation and the such USB ports are becoming more commonplace on panels for charging but this seems to be more common in GA planes currently.