Why is the iPod Touch 5th gen able to record 1080p yet the iPhone 4 isn't?
Camera sensors are not only limited in their resolution, but also in the rate at which the image data can be read off of them.

Just because a sensor can take 5-megapixel still images doesn't mean that all of that data can be read off the sensor fast enough to record (smooth) video. Even reading just a subset of the pixels (called pixel binning) to reduce the amount of data may not be enough to get 1080p images at, say, 30 frames per second.

A web search indicates that the iPhone 4 uses an Omnivision OV5650 sensor. According to Omnivision's own product sheet for that sensor, it's limited to 720p video, so it's not just a software thing. I couldn't find any specifics about the sensor in the new iPod touch, but it's almost certainly a different one if it records 1080p.