Marrakech was founded in 1070 by the Almoravid dynasty primarily to serve as their capital city and a strategic military base. This location allowed them to consolidate their burgeoning empire and control crucial trans-Saharan trade routes, quickly establishing it as a major political, economic, and cultural center.