If I'm not mistaken the first permanent "embassies" were set up by the Venetians (mostly) and the Genoese, and their role was essentially just that, i.e. protecting the economic interests of their "home" entities. It so happened that most of the time protecting the citizens who happened to reside in foreign countries also meant protecting their home-city economic interests, but that mainly happened because the citizens involved were traders themselves. So, in a way, you could say that what the Department of State is now doing is just the continuation of the initial idea of a "foreign embassy".