That's because you skip items while removing from the live nodelist.
When you remove the item at index 0, the item which was at index 1 takes index 0, so you don't remove it as your iteration is already on index 1.
Do it like this :
function remove_inputs(){
var elements=document.getElementById('thediv').getElementsByTagName('input');
while(elements.length){
elements[0].parentNode.removeChild(elements[0]);
}
}