Why does islam provide a death penalty for infidels?

Islam provides death penalty for infidelity. The question is why? Some religious scholars say it is not about executing someone who changes his/her mind, but about not allowing to promote infidelity. It means if someone leaves Islam and does not talk about it in public, he/she is safe. But others agree that it is about power and control.