In all current cases there aren't very many people trying to cross the border at once. If Egypt became uninhabitable there'd be 100 million people trying to leave. If it was even just 5% of that trying to get in to Israel then a wall or an army isn't going to stop them unless that army is willing to actively murder innocent people. I don't think any army on Earth would be willing to do that. Consequently a military solution isn't ever going to work.