Owing fealty to the personage crowned as Emperor of the Romans, King of the Germans was never a voluntary arrangement. First, it carried rights, such as a seat in one or more colleges of the Imperial Diet, and possibly the right as a Prince-Elector to vote on succession to the imperial titles. Second, it carried the (nominal, to be sure) responsibility of fealty to the crowned Emperor of the Romans, King of the Germans, commonly referred to as the Holy Roman Emperor, in whom for almost all of its history the two titles were unified.
This duality of rights and responsibilities means that it was in the mutual interest of both emperors and imperial immediates to protect their relationship, by accurately tracking imperial domains. The sovereign states whose sovereign princes possessed these rights and responsibilities occasionally changed, but always (and only) de facto by force of arms and subsequently de jure by ratified treaty.
Note that as the practical powers of the Emperor diminished, the motivations for attempting separation from the Empire diminished. Other powers such as France and Spain were, from 1453 and 1492 respectively, more than capable of swallowing stray independent principalities lacking a strong protector. Despite lacking any real power over much of the Empire, Emperors throughout its history regarded it as their sphere of influence and could usually be relied on as an ally against stray foreign ambitions.