State governments fund and run primary elections in much the same way they do the general election in the fall. Voters go to a polling place, vote, and leave. The primary election was a Progressive-era reform intended to reduce the potential for mischief in a nomination system controlled by the parties.
BobE mentioned, this is the "mischief" which led to such reforms: https://ivn.us/2015/07/30/story-behind-pay-party-primaries/
Furthermore Bullock v. Carter in '72 solidified these reforms.
In essence, state funding became an obligation in order to circumvent issues such as requiring endless fees to lock competition out of an election. Parties were rigging elections through financial burdens.
Disclaimer: Certainly I am neither endorsing the necessity of this system nor am I claiming it is the only way to defend against rigging via finances. Simply put, this explains why states became the source of funding.