Aswamedha yajna was a royal rite. It was done only by the Kings to spread their glory throughout the world and for the benefit of their kingdom (rāṣṭram vā aśvamedhaḥ). Regarding its origin and usage of horses the Brihadaranyaka Upanishad says:
सोऽकामयत: मेध्यं म इदं स्याद् , आत्मन्व्यनेन स्यामिति ततोऽश्वः समभवद् यदश्वत् , तन्मेध्यमभूदिति तदेवाश्वमेधस्याश्वमेधत्वम् [Brh. Up. - 1.2.7]
He (the first purusha or Brahman) desired "let this (his body) be fit for sacrifice(medha) and let me be embodied by it". Then he became a horse as it swelled. He thought, it has become fit for sacrifice. Hence, the horse sacrifice is called as Aswamedha.
The sacrifice itself has been mentioned in the Vedas (taitariya samhita, 7th khanda). So its origin is prehistoric. From scriptures like Ramayan (Bal Kanda) Mahavarat (Aswamedha Parva), etc. their performance and processes are known.
It was also beleived that one who performs 100 Asvamedha yanjas obtains the position of Indra in heaven. So Indra tries to create hindrances in such performances.One One example is the Indra's stealing of King Pṛthu's horse on his final horse sacrifice. Also, Bali, grandson of Prahlad, tried to perform 100 Aswamedha yanjas after which he would have been the king of gods. So Lord Vishnu in the Vaman incarnation hindered his completion of 100 Aswamedha yanjas by taking away everything from him .