Apps that you get through the app store would still work if you unjailbreak, that is, restore your Touch to stock firmware.
Apps that you get from sources other than the app store, including those you install through cydia or installer, would no longer work if you unjailbreak.
And no, jailbreaking isn't illegal. (I've heard some arguments that it breaks some sort of law against cracking encryption, but I really doubt that law actually applies to jailbreaking)