Should the desire to go back to one's country after graduation be written in the statement of purpose? I wish to apply to public universities in the US for a PhD in the near future and at this point I am drafting my statement of purpose. 

Having been exposed to how research (majority of which is public and funded by the government) is done in my country (India) from an early age and having worked in some of these research organizations myself, I was considering including a desire to be an active part of the academic community (in what capacity, I don't think I can be sure at this point) in India and possibly working to contribute to it as one of my motivations for gaining a PhD. 

Given that I wish to apply majorly to public research universities (majorly funded by the governments, as I understand it) in the US, will it be perceived as not being in the interests of the university to accept a student who is keen on returning to his country following his education? Does this kind of a thing matter during the admissions procedure? Should I be thinking along these lines? How is marginal patriotism this kind of a motivation perceived in a statement of purpose?
Depending on your wording (and to a lesser extent on your discipline), I do not think this is problematic at all. Most public universities in the US are not directly concerned with the monetary investment in their students.

Rather, they are concerned with attracting motivated, high-quality graduate students along with an undergraduate student body that contains (and serves) many students from the state but also includes students from diverse backgrounds and with different life experiences.

You do not say in your question whether you are pursuing a graduate or undergraduate degree, but I think in either case it's fine. Having a plan to return to your home country is totally understandable, and speaks to both your motivation and long-term planning.

Furthermore, admissions committees understand that while you have this plan now, that things can happen over the course of years and that you plans you outline in your statement of purpose may change.

As multiple comments and answers indicate, this should not be the main focus of your statement of purpose and does not need to be belabored.

I agree with the comment that "patriotism" is not quite the right word for your preferences, and I think using that word (or some others) would seem strange or inappropriate in your statement, but in general, expressing a desire to eventually apply the skills you will be learning in your home country should not be a problem.