The ultimate goal is to be released from the merry-go-round altogether. And that release is called Moksha. The law that holds all this together is Karma, which is summarized really nicely in the Aranyaka Upanishad. The doer of good becomes good. The doer of evil becomes evil. One becomes virtuous by virtuous action, bad by bad action. The Upanishads, by the way, are later religious texts that began as commentaries on the Vedas but later became sacred writings in their own right.