In most cases this should be relatively easy to fix. You can generate a list of all installed packages using the /lib directory with:
dpkg -S /lib | awk -F': ' '{ print $1 }' | tr -d ,
If you reinstall these packages, then it should fix the issue:
apt-get --reinstall $(dpkg -S /lib | awk -F': ' '{ print $1 }' | tr -d ,)
This of course depends on the deleted directory not being critical for apt-get. Packages required for apt-get to work would have to be installed manually, perhaps even without dpkg. In this case the package could be extracted on another machine and the files copied into place, they would later be re-installed with apt anyway so this shouldn't cause any other problems.
Looking at my own list of packages putting files in /lib, I see that major ones are the kernel (all modules go to /lib/modules) and libc. These are two that would almost certainly have to be reinstalled for the system to be bootable. One way to do this would be to install from a live Debian based system. If you download the necessary packages and mount the root of the target system, you can add the --root option to the dpkg there to install, eg:
dpkg --root=/path/to/target/root -i package1.deb package2.deb ...
The --root option could also be used with first dpkg command if necessary. Of course with enough patience and skill, it should be possible to repair online. If the dpkg command fails to work, you can always attempt to look up package dependencies directly in /var/lib/dpkg/info and search for packages putting files in /lib via the .list files in /var/lib/dpkg/info.
To give an idea of what can be achieved, here is a blog about someone who managed to recover a running Gentoo system where all the packages had been uninstalled. It makes for an interesting read, plus some of the techniques used (or the one suggested in comments) could be applied in this kind of situation - http://fakeguido.blogspot.co.uk/2010/08/rescuing-hosed-system-using-only-bash.html