I guess, it did not "come from" -- it was always there. ;)

Russian (as well, as Latin, Greek, Sanskrit...) it descendant of common Proto-Indoeuropean language. I'm almost sure it had cases. Of...