How do I upgrade an iPhone 4 from iOS 7.1.2 to iOS 8 or 9
You can't upgrade an iPhone 4 to a newer version than 7.1.2. iOS 8 only supports iPhone 4S to iPhone 6 Plus. iOS 9 supports iPhone 4S to iPhone 6S Plus/iPhone SE.

An iOS support matrix is available here: iOS Support Matrix (additionally: pdf download)