Tenure is given to faculty for the same reason as legal protection is given to whistleblowers. You can think of it as a witness-protection program of sorts.
The essential part of the job of an academic is pursuit of truth and teaching and assisting the students in these endeavors. New truth usually comes to the mind of one person before it is generally accepted. Between these to points in time --- the discovery and acceptance --- the discovery and its inventor are often unpopular. More often then not, the holders of previous views are entrenched and powerful. You probably are well aware of how long it took for the Church to accept that the Earth was round, while it burned at the stake quite a few people for that heresy: in one of the more famous cases, Giordano Bruno was burned at the stake in 1600, it took the Church almost 300 years to admit that it was a mistake.
In order to encourage the search for truth and protect the discoverer of the unpopular facts, faculty members are given tenure. This protects the faculty member from the administration --- the deans, provosts, presidents --- and allows the instructor to speak his or her mind in class.
From economic standpoint, it is a form of insurance without which the inherently risky endeavors will not be undertaken.