You may want to read several threads that discussed this topic. Given that their rule in Spain and Germany spanned many centuries, do you have a particular region or period you are interested in?
http://www.reddit.com/r/AskHistorians/comments/2l121z/how_did_the_habsburgs_get_elected_as_holy_roman/
http://www.reddit.com/r/AskHistorians/comments/32fpf0/how_did_the_habsburgs_rise_to_power_in_the_holy/
http://www.reddit.com/r/AskHistorians/comments/1kmycg/just_how_did_the_habsburg_family_managed_to_get/