How does inflection evolve in languages?
This question has been dealt with in literature on grammaticalization. The Wikipedia entry has all the detail to get you started on further research.
In short, there are a number of processes through which lexemes lose their original meanings and through processes like enclitization become morphemes. We can even see some of these in progress as in the English will going from will=want to 'll.
This type of development has been famously summarized as:
content word → grammatical word → clitic → inflectional affix
Original answer: Linguistics Stack Exchange. Licence: CC BY-SA 3.0. Original question by shuhalo: How does inflection evolve in languages?.