The Infield Fly is defined in Section 2 of the Official Rules of Major League Baseball, which is unfortunately copyrighted, so the exact definition can't be transcribed here. The requirements for an Infield Fly are as follows:
There must be fewer than two outs.
There must be a runner on first and second. There may be a runner on third.
The ball must be hit in the air and be catchable by an infielder with "ordinary effort". The definition of infielder includes the pitcher, catcher, and any outfielder positioning themselves in the infield.
The ball must be not be foul.
It is the duty of the umpire to declare Infield Fly as soon as possible. Should the ball be hit along the baseline, it should be declared "Infield Fly if fair". The Infield Fly is NOT defined by where the ball lands or who it is caught by -- it can land in the outfield or be caught by an outfielder, as long as in the judgment of the umpire it could have been caught by the infielder.
What happens to the batter in this situation is defined in Rule 6.05(e), which explains all of the circumstances under which a batter can be ruled out. An Infield Fly takes precedence over another rule, 6.05(l), which states that the ball is dead if an infielder intentionally drops a fly ball with runners on base and less than two outs. In the case of an Infield Fly, the ball is live.
The Infield Fly was added to the rulebook in 1885, the same year that foul tips became strikes, and players other than catchers and first basemen were prohibited from wearing oversized mitts. As mentioned above, the reason for the rule was to keep sneaky infielders from letting the ball drop on purpose in order to turn a double play. The rule was introduced by sportswriter Henry Chadwick and baseball pioneer Alexander Cartwright.