In representation theory one is interested in groups and so one studies representations of them, representations lead naturally to modules, and modules lead to more general rings. So in that setting modules come first and rings second, which is opposite of the development you've suggested. Another surprising reversal: characters were defined and studied by Frobenius [Uber Gruppencharaktere, 1896] a full year before he defined representations [Uber die Darstellung der endlichen Gruppen durch lineare Substitutionen, 1897]; which is surprising because most current mathematicians don't even know how to define a character of a non-abelian group without using representations in the definition.
This should suggest to you that trying to discern historical motivations from the current utility of the theorems/objects is fraught with problems and that the modern path to introduce mathematical objects often bears no resemblance to the historical path taken to their discovery/definition.
As for what the actual historical development was I'm no expert. The modern axiomatic notion of a ring and its ideals was formalized by Emmy Noether [Idealtheorie in Ringbereichen, 1921] but those concepts had certainly existed previous to that paper, albeit informally. Noether is also responsible for introducing the notion of a module [Hyperkomplexe Grossen und Darstellungstheorie, 1929]. I don't know if this concept predates her or not, but I believe her interest in it was as a method of studying representations of an algebra, not as a method of embedding the algebra into a nicer space of objects.
What I can say for sure is that the idea of embedding rings into the category of modules and using the methods of homological algebra were definitely not motivations in the initial development of module theory. Category Theory was first defined by Eilenberg and Mac Lane [General Theory of Natural Equivalences, 1945]. You can trace some of the ideas back to an earlier paper from 1942, but they definitely weren't around in the 20's. Homological algebra was around as early as the 20's, and Noether played a part in it, but the only notion that existed at the time was that of the homology groups of a topological space. So homological algebra was 100% a subset of the study of the topology of spaces. It did not play a role in the study of purely algebraic objects until around the 40's. So neither of those concepts would have been a factor in the first developments of module theory.