Sometimes a person needs what he does not own and he owns what he does not need. For example, a person has saffron but needs a camel for transportation and one who owns a camel does not presently need that camel but he wants saffron. Thus, there is the necessity for a transaction in exchange. However, there must be a measure of the two objects in exchange, for the camel-owner cannot give the whole camel for a quantity of saffron. There is no similarity between saffron and camel so that equal amounts of that weight and form can be given. Likewise is the case of one who desires a house but owns some cloth or desires a slave but owns socks, or desires flour but possesses a donkey. These goods have no direct proportionality so one cannot know how much saffron will equal a camel’s worth. Such barter transactions would be very difficult.
Various forms and types of goods such as these need a medium which could rule justly and determine their value or worth according to their place in exchange. When their place and grades are ascertained, it is then possible to distinguish which one is equal to each other and which is not. Thus, Almighty Allah created dinars and dirhams as two rulers and media of exchange for all goods and the value of goods is measured through them. So it is said a camel is, say, equal to 100 dinars and this quantity of saffron is worth 100 dinars. Since each of them is equal to a given amount, the two quantities are equal to each other.
This equality of worth or value becomes conveniently possible through dinars only because those dirhams and dinars are not needed for themselves… A thing (such as money) can be exactly linked to other things if it has no particular special form or feature of its own — for example, a mirror which has no colour but can reflect all colours. It is the same with money — it has no purpose of its own, but it serves as a medium for the exchange of goods.
– Al-Ghazali (died 1111 AD), quoted in “Economic thought of Al-Ghazali (450-505 A.H. / 1058-1111 A.D.)” by S. Mohammad Ghazanfar and Abdul Azin Islahi, Islamic Economics Research Series, King Abdulaziz University, 1997.