The formal name for crossing in biology is decussation. It is thought to be a result of anatomical development as well as a recovery mechanism. Essentially, it's an emergent result of negotiations between genetics, development, and environment. I've emphasized the relevant sentences in two abstracts below.
Abstract: The crossing of nerve tracts from one hemisphere in the brain to the contralateral sense organ or limb is a common pattern throughout the CNS, which occurs at specialised bridging points called decussations or commissures. Evolutionary and teleological arguments suggest that midline crossing emerged in response to distinct physiological and anatomical constraints. Several genetic and developmental disorders involve crossing defects or mirror movements, including Kallmann's and Klippel-Feil syndrome, and further defects can also result from injury. Crossed pathways are also involved in recovery after CNS lesions and may allow for compensation for damaged areas. The development of decussation is under the control of a host of signalling molecules. Growing understanding of the molecular processes underlying the formation of these structures offers hope for new diagnostic and therapeutic interventions.
Vulliemoz, S., Raineteau, O., & Jabaudon, D. (2005). Reaching beyond the midline: why are human brains cross wired?. The Lancet Neurology, 4(2), 87-99.
Abstract: Many vertebrate motor and sensory systems “decussate” or cross the midline to the opposite side of the body. The successful crossing of millions of axons during development requires a complex of tightly controlled regulatory processes. Because these processes have evolved in many distinct systems and organisms, it seems reasonable to presume that decussation confers a significant functional advantage—yet if this is so, the nature of this advantage is not understood. In this article, we examine constraints imposed by topology on the ways that a three-dimensional processor and environment can be wired together in a continuous, somatotopic, way. We show that as the number of wiring connections grows, decussated arrangements become overwhelmingly more robust against wiring errors than seemingly simpler same-sided wiring schemes. These results provide a predictive approach for understanding how 3D networks must be wired if they are to be robust, and therefore have implications both for future large-scale computational networks and for complex biomedical devices.
Shinbrot, T., & Young, W. (2008). Why decussate? Topological constraints on 3d wiring. The Anatomical Record, 291(10), 1278-1292.