Obviously colonies like the British Raj and French Africa provided a wealth of resources and labor. But in the case of the vast majority, I’m very confused as to why any nation would waste its money and military upholding them. Take the Philippines, for example. Did it serve the US any purpose other than as a place for military bases and a source of “prestige?”
The motivations behind European colonialism were highly diffuse, and any analysis must be contextualized within the relevant time period. Needless to say, colonialism provided a number of economic benefits at any stage of history, though the precise nature of these benefits changed alongside the mode of production. You mention American acquisition of the Philippines, an event which can be viewed in the context of late 19th century colonialism as a whole. As a product of industrialization and increasingly protectionist trade measures, markets throughout the Western world had become oversaturated, necessitating large-scale colonial endeavors such as the Scramble for Africa in order to secure new markets and resources. These same financial interests catalyzed American colonization of the Philippines.
American colonization of the Phillippines facilitated an expansion of American-Philippine trade relations, and legislation such as the 1906 Philippine Free Trade Act enabled open access to the Phillipine market. In a highly protectionist global market, such an arrangement rendered the Philippines highly dependent on American trade; between 1899 and 1920, american imports grew to represent 66% of the Philippine economy (Reyes 1923). Though the balance of trade remained in the Philippines' favor, "this [was] returned to the United States in the form of service items, shipping and insurance, interest and dividends on invested capital and payments of loans". Moreover, many Philippine exports were produced and sold by American-owned firms, and roughly half (49% in 1933) of exports were carried by American vessels; as a result, the trade deficit remained relatively inconsequential (Porter 1940).
Colonial involvement in the Philippines also presented the opportunity to enter east asian markets. Initially, American officials mainly viewed the Philippines as a conduit for trade with the east following the opening of the chinese market through the open door policy. McKinley actually entered the Paris Treaty negotiations with the intent to demand no more than Manila (which McKinley envisioned as a key port for trade with China) and the establishment of several bases on Luzon, though, on the advice of his generals and Republican advisors, he quickly escalated his demands. However, the fact that McKinley entered negotiations intending to request only a port city demonstrates the primary US motivation for entering the Philippines: the establishment of trade relations with China (Miller 1982).
Additionally, American business interests in the Philippines incentivized their retention as a colony. Although congress limited the land holdings of american corporations in the Philippines in order to prevent competition with domestic goods, the "centrale" system - whereby "sugar mills...ground cane supplied by surrounding large landowners, small proprietors, and tenants" - allowed them to partially bypass these regulations. By 1934, American investors controlled roughly 28% of sugar production overall; to comprehend the magnitude of this interest, bear in mind that sugar contemporaneously represented 2/3 of Philippine exports to the US, whose market received 87% of their exports overall (Friend 1963). American capital remained dominant in several other industries as well:
Americans controlled in 1938 nearly 44% of public service enterprises, including transportation, electric plants, ice plants, telephones, water systems, and gas; their investment represented 42% of the total in the sawmill industry; and their stocks controlled about 60% of the total gold reserve of the islands. (Porter)
Lastly, American access to Philippine resources served as a major motivation for annexation. Timber and metal deposits incentivized colonization, but the extent to which their potential was realized is debatable:
During the seventeenth century, rumors of rich Igorot gold mines had brought Spaniards into the Cordillera, but they were successfully repulsed. By the ninteenth century, the Spanish had abandoned efforts to mine the ore themselves. U.S. officials believed that they could succeed in tapping into this fabled store of wealth.
...
American hopes of taking large yields from these mines had diminished by the time the handbook had rolled off the press...Most of the ore in the region was low grade, requiring expensive machinery and multiple lodes to extract profitable quantities of gold. (Barclay 2003)
Regardless of whether precious metal extraction provided long-term benefits, the desire for precious metal accumulation still drove american expansionism. Furthermore, access to various other Philippine resources proved valuable in the long run; access to Philippine sugar, for instance, allowed America to avoid the worst of the WWI and 1925 sugar depressions (Friend).
The interests of America in the Philippines were a synecdoche of European colonial interests at the time. Market oversaturation forced the acquisition and monopolization of new markets, business interests profited immensely from resource extraction, and resources helped fuel further industrialization. So, to answer your question, these reasons compelled colonial powers to pursue imperial ambitions.
For further reading on American colonization of the Philippines, I'd highly recommend Stuart Miller's "Benevolent Assimilation: The American Conquest of the Philippines, 1899-1903", which is available on libgen.
Citations:
Edit: spelling;