I'd like to clarify a few things as there is a LOT of misconception out there about how computing devices can be compromised. I like to refer to this misconception as the "CSI effect" - what makes for good TV is not necessarily based on reality.
Let's start with the basics. Your iPhone/iPad/iPod Touch is a computer like any other. Just because it works like a cell phone, doesn't make its nature any different. Computers can't do anything they are not programmed to do. Its mission in life is to run programs, created by humans. It can't contract an illness like a person can, just by being exposed to it. Yes, there are some parallels between how a computer virus behaves like a biological virus, but these are strictly aesthetic and don't work the same way under the surface. Knowing that allows you to look at some of the more sensational articles going around with a more skeptical eye.
One of the things that Apple is regularly criticized for with their iOS devices is that they operate within a "walled garden". That is, your iOS device can't run *any* programs that Apple hasn't explicitly put their stamp of approval on. This is the reason you can't run Flash, because Apple has determined that they don't want it running on iOS.
This approach has some pros and cons. On the positive side, it pretty much eliminates the possibility of a virus or other form of malware like spyware. Even if a bad guy wrote a program designed to monitor your every move, without getting approval from Apple, it simply won't run on your iOS device. The only time that's not true is if Apple has left some kind of security hole or bug in the operating system that a hacker can use to force the program to run. This is what is known as an "exploit". Exploits are often found in every computer operating system under the sun, and typically the manufacturer is notified of the condition and they patch for it rapidly. But occasionally one slips out before the manufacturer has recognized it. This is what is known as a "zero day exploit". These are usually pretty far and few between, but it does happen. When it does, Apple is usually pretty quick to put a patch in place that closes the hole.
Another thing that can happen (and again, it's pretty rare) is that Apple will approve an app for the App Store that has some kind of undesirable program within it, but its disguised as a desirable program. In these cases, Apple will typically pull the program from the App Store, ban the developer from publishing new software and they also have the ability to "kill" the app from your iOS device without your consent. These events are extremely rare and when they happen, are usually well publicized.
The negative aspect to this "walled garden" approach is that you can only run software that Apple thinks is OK. A good example, mentioned earlier, is Flash. While iOS devices are technically capable of running Flash, Apple has decided that it's in your best interest that it isn't available. There are also frequent examples of situations where Apple has approved a piece of software, but upon further consideration, decides that they don't want people running it and so they'll pull it from the store. This frequently happens with apps that Apple has a moral or ethical problem with - or in cases where someone has asserted an intellectual properly claim upon an app published by another entity. A good example of this is when someone published a Tetris clone before EA (the rights holder) had a chance to publish the official Tetris app for iOS. Apple pulled the (free) clone and the only option for iOS device users was to buy EA's Tetris.
With that said, you can "jailbreak" your iOS device. When you do this, you are simply removing the protection mechanisms that are put in place to enforce the walled garden. You can run whatever software you wish - but you are doing it at your own risk. It's not entirely simple to do so either, since jailbreaking it means that you're making fundamental modifications to the OS that have the potential to "brick" your device if applied incorrectly.
Jailbreaking software typically takes advantage of the aforementioned known exploits in the OS in order to run - and to do it requires physical access to the device and a certain amount of effort applied on your part. You can't, for example, simply have a chance encounter with a hacker and have your phone jailbroken unbeknownst to you - which is a frequent scenario played out on popular TV shows. Also, since Apple is usually pretty good at patching for these exploits, they frequently will negate the jailbreaking software by releasing an OS update. The moral of this story is that if you like the protection afforded by the "walled garden", it's a good idea to update your iOS device as soon as a new update is released.
Now, full-blown computers like the Mac, Windows and Linux machines are different in this regard as they allow you to run whatever software you want to, without seeking the OS manufacturer's permission. The same applies to Android devices to a degree. And it is for that reason, that it's more likely you'll encounter some form of malware on one of those platforms.
Hope that makes sense - and let me know if any of your questions remain unanswered.