As many people have suggested screen and tmux, they both support basic functionality, but have distinct specific features, so one can't say that one is superior to another in all cases. For example, only tmux supports Window-splitting, while only GNU screen can toggle long line wrapping with (Ctrl+a r). See more detailed comparison here.
There also exist tools specifically to fix this problem of ssh:
Autossh is a program to start a copy of ssh and monitor it, restarting it as necessary should it die or stop passing traffic. The idea is from rstunnel.
Mosh is a remote terminal application that allows roaming, supports intermittent connectivity, and provides intelligent local echo and line editing of user keystrokes.
Mosh is a replacement for SSH. It's more robust and responsive, especially over Wi-Fi, cellular, and long-distance links.