Japanese style housing is different from western style. Often they have soft floors(like mats) and tables near the ground. You sit on the floor. It would be common sense not to wear dirty shoes inside such a house. I suppose that tradition kept going even though they may have hard floors.
Its like the same reason you dont put your shoes on the couch.