The Law of Karma has often been used to justify or explain the evil and disparities in the world. However it creates a division between the world and God, in a sense that this creates almost a mechanical law of action and reaction that goes on impersonally, mathematically so to say within the cosmic egg while the Divine Being is simply a mute witness to this process. He can neither alter it nor abrogate it. This makes the Divine Himself as someone mechanical whereas makes the human will suddenly a most important factor that operates in a blind mechanical determinism of Nature.
Another way is to see this world as not a mechanical unconscious process, where a Divine Being is somewhere above, only witnessing His creation after giving it the original push, but also see a Divine Consciousness that is dynamically engaged in all its functioning and processes and activities. The first theory leaves a gap between the Creator and Creation but the latter bridges it. When we understand the law of karma against this background, we look at it as part of a grand Divine plan whose original purpose is not reward and punishment but to objectify Himself through the Creation. This gives a purpose and an intention to creation where each unit is being carried forward, even despite itself towards this great Divine becoming. This evolutionary push from within is inevitable in the very stuff of things.
But all evolution implies a struggle between the forces of past and those that are drawing towards the future. At times this struggle becomes too acute and a crisis ensues. The paradox is that during such crisis the evolutionary energy forces itself and the form or the species takes a sudden leap. It is a Grace and not a punishment when there are challenges in life. Of course one wishes that the evolution could be painless and smooth but that needs a surrender of the forces that hold the old world order to the forces of the Future. It is this unwillingness of the subconscient past to yield that constitutes the struggle. Besides these forces having shaped the material life of earth have a far greater hold upon it than the forces of the Future that have to be first accepted and then assimilated. Once that is done then the struggle eases out largely but until then one cannot help but go through the pain. It is this struggle of matter that is often reflected in such instances as you speak of. The deformations are because three main reasons. First and most common, especially when there is a mental retardation also is that it is a transition from the animal to the human birth, a first birth so to say leading to queer half way sub species, that looks somewhat human but is not yet so. The soul is hardly there within it so there is no question of the law of karma and conscious choices. Evolution is still largely at an animal stage so to say. The second reason is that the soul that inhabits it is not yet developed enough to exercise enough influence to determine a wholesome physical shape. Through this passage the soul grows in strength as mentioned above. The third reason is that the soul has advanced beyond a point but wants to take a leap and hence takes hold of an imperfect body shapes through heredity to give it the kind of experience it needs to leap forward. One can see this in the case of a yogi like Astavakra or a scientist like Stephen Hawking. But apart from these reasons this world being still largely under the influence of vital and undivine forces does bring into play plenty of disorders, chaos, deformity, perversity and ‘accidents’. All cannot be rational in a world still governed by infra rational and irrational forces.
This is as far as the larger lines of evolution go. Where does sanchit and prarabdha karma fit into this. Sanchit karma literally means the accumulated energy from the past lives whose experience is yet to be exhausted fully for the soul to move forward. But these are too many and too complex curves of destiny along which the soul has moved. Hence it chooses out of its store of unfinished curves of sanchit karmas a particular selection for one life. This selection of karmic energies becomes the prarabdha karma which the soul chooses to undergo in a particular life. It may be related to a deformed body as in the case of certain developed souls (though this is rare) but more commonly it relates to the circumstances of life through which it moves to expand the energies of its soul and learn through failure and grow through fall. What is more important however is that beyond the law of Karma there is the Divine Compassion that leans over the diseased and the distressed and the deformed to succour and relieve or open avenues of progress through this. And beyond Divine Compassion there is the Divine Grace that can completely change Destiny, often without even our knowing it.