What is the real benefit of tenured positions for universities? People are interested in tenured positions to have a secured job, as they do not need to worry about their contracts. Tenured position gives a professor security that s/he cannot get fired easily (e.g., simply not renewing his/her contract). But, what is the actual obligation for the professors? In return, what is the motivation for a university to offer tenured position, which is accompanied by less flexibility from HR point of view.

Apparently, tenure is just for the sake of academic freedom, and has no real benefit for the institution, except a one-way service to professors (probably satisfying more applicants). Am I right? Then, a university must prefer not to offer tenured positions at all, as HR has more freedom with non-tenured positions.
Institutions offer tenure, not (just) because of high-minded abstractions like "academic freedom", but because it makes good business sense.  The benefit of tenure to the institution follows from the benefit to the individual:


From the faculty member's perspective, tenure makes it possible to pursue high-risk/high-impact research ideas without having to worry about having to keep short-term bean-counters happy.  
This makes institutions that offer tenure more attractive to strong researchers because those researchers want an environment that best supports their ability to pursue their research ideas.  
Such researchers, in turn, are very often also the ones who bring in the big grants.  Their high visibility also enhances the reputation of the institution, which attracts more students and alumni donations, etc. etc.


For these reasons, given two otherwise-identical institutions where one offered tenure and the other didn't, the one without tenure would find itself at a significant competitive disadvantage.