For starters Maximilian rejecting the offer butterflies parts of the French Intervention, so the state of the opposing forces in later conflicts also change. The French may pull back from the country sooner than IOTL after their candidate rejected the crown and the Mexicans proven hostile to occupation. That said, for Maximilian to become king of Spain there would have to be some changes in the aftermath of the 1868 revolution in Spain. IOTL the Habsburgs were not seriously considered as candidates due to the folly in Mexico, but they would still be secondary candidates. On the frontline, as OTL, it is likely that the liberals promote the candidature of Ferdinand of Coburg as king, him being the father of the king of Portugal, with the liberals hoping for an Iberian Union and Ferdinand rejecting the crown as he feared his coronation in Madrid would result in Spain annexing Portugal. As for the conservatives, they supported the Bourbon Duke of Montpensier, but he got disqualified after he killed another Bourbon in a duel (plus Napoleon III wouldn't approve another Bourbon in Spain). So then the Spanish turned to other candidates, and that's where Maximilian could come in. The Habsburgs ruled Spain for close to two centuries, and they were supported in parts of the country, especially in the east where there were hopes of restoring the Fueros of the former Crown of Aragon (which wouldn't happen anyways). Maximilian would be more palatable to the European powers than Leopold of Hohenzollern, and there were complications with choosing an Italian candidate.
That being said, even if Spain had a Habsburg monarch, I think Spain would not side with the Central Powers. After all, the Germans proved to be quite antagonistic to the Spanish in the latter third of the 19th Century, trying to snatch the Caroline and Mariana islands from them and resulting in a crisis that had to be mediated by the Pope; the German claims in Equatorial Africa overlapped with the Spanish claims dating back to the Treaty of El Pardo; Germany exerted pressure on Spain to lease a minor Caribbean island; and the Germans also interfered in the Franco-Spanish attempts to establish a protectorate over Morocco. Spain was also dependant on British coal, with Britain and France being its largest trade partners. Hispano-German relations may have been positive up to the 1880's or 1890's, but after that point I see Spain trending towards a more neutral policy in European affairs, especially after the Franco-British agreements, which would surround Spain should they side with the Germans. Being a relatively poor country with no major territorial aspirations nor irredentist claims against its neighbours, there is very little incentive for even a Habsburg-ruled Spain to fight on the side of the Central Powers.