Nippon and
Nihon, the Japanese names for Japan, are two variants of the same Japanese name (日本), which is itself borrowed from two
Chinese words meaning "
sun source". In
modern Chinese these may be pronounced
ri-ben, but ancient Japanese borrowed the words from ancient Chinese at a time when both languages were pronounced rather differently. The two would have been something like
nit-pon in
Old Japanese.
The regular development of this name was for the T to assimilate to the P, giving Nip-pon. Then there was an irregular loss of one of the P's, giving the form Ni-pon. (Normally double consonants have been preserved in Japanese.) Both forms must have been current together from an early period.
Then the sound P suffered further changes in the history of Japanese. In most circumstances it changed from P to F, then later to H. This is how Nihon arose. There would have been an intermediate stage Nifon.
In two circumstances, P did not change to F then to H: after the nasal consonant, and when doubled. So Nippon stayed with its P, while Nipon became Nihon by regular sound change.
The word 'Japan' itself has the same origin. Mediaeval Europeans also called the country Zipangu or Cipangu. The -gu is the Chinese word for 'country', modern Chinese guo, modern Japanese -koku/-goku. Note that the letter R in the Pinyin transcription Riben would be written J in the old Wade-Giles system, so it's not a pure R sound, it's a buzzy sound resembling a Z. So Japan, Cipan, Zipan, Riben all indicate that the earlier pronounciation of the syllable Nit- must have been closer to jit-. I wish I knew more about Old Japanese and could be definite on this.
The two Ancient Chinese words that became the modern names Nippon, Nihon, and Japan, were around 600 (early Tang dynasty) pronounced roughly nzhiet-puen (I can't do justice to the diacritics, so that's only rough).
The element nzhiet meant 'sun' or 'day', and was borrowed twice into Japanese, from different Chinese dialects: once as zitu and once as niti. It is the second one of these that was used in Nippon.
The element puen was originally a picture of a tree root (it still looks like a tree), and so from root it came to mean origin and suchlike. So Nzhiet-puen = Sun-origin = Land of the Rising Sun.
Nippon is the more conservative form, so during the War they would always have said Dai-Nippon, 'Great Japan', not *Dai-Nihon. However, only the Nihon form is used in compounds such as Nihongo 'Japanese language' and Nihonzin 'Japanese person'.
For further information by real experts, read the write-ups under Japan by sensei and Myrmidion.