Walking requires mechanical energy, because it involved accelerating and lifting a mass. That energy has to come from somewhere. Your body isn't built to run on solar panels, or a windmill, or a nuclear reactor, so the only place you can get the energy is from putting food into yourself and letting your stomach and guts do chemical reactions with it.