Probably the reason it threw a code (if it was the full intake) is that they make more power (and maybe increase fuel economy slightly) by increasing the diameter of the tube where the MAF sits. This causes more air to flow than the ECM thinks is flowing, thus leaning out the mixture. Factory engines are tuned a little on the rich side to prevent excessive detonation (especially if you get some bad gas). So by leaning the mixture slightly you can gain a few (very few on these engines) HP. If it is too lean the ECM will detect it and throw a code.
This is a 'low budget' method of increasing power and is frowned on by engine tuners. Most of the time it works fine, but if you get some bad gas you could run too lean at full-throttle and fry the motor (though they usually only lean it out a 'safe' amount). A tuner knows just how far to push the mixture; a one-size-fits-all mod like a K&N intake works most of the time but usually with minimal gains.
If you get the car tuned (on a dyno, by someone who knows what they're doing), you can probably get more power from the engine with the stock intake than you gain with the K&N (and no tuning) since the power increase is not from more intake airflow but from leaning out the mixture (these motors have more than enough intake airflow from the factory without any mods - they use the same intakes on the S/C motors and they need a LOT more airflow than the N/A motors will ever need). But the amount of power gained from a dyno tune would not be worth the cost (IMHO). As I said in my post above, my truck will always be a slug. If I want to go fast I drive something else. If I want to go 'anywhere' I drive the 4Runner.