Recent progress toward the fabrication of Majorana-based qubits has sparked the need for systematic approaches to optimize experimentally relevant parameters for the realization of robust Majorana bound states. Here, we introduce an efficient numerical method for the real-space optimization of tunable parameters, such as electrostatic potential profiles and magnetic field textures, in Majorana wires. Combining ideas from quantum control and quantum transport, our algorithm, applicable to any noninteracting tight-binding model, operates on a largely unexplored parameter space and opens new routes for Majorana bound states with enhanced robustness. Contrary to common belief, we find that spatial inhomogeneities of parameters can be a resource for the engineering of Majorana bound states.