The firing port idea was a logical extension of the problems of fighting in an NBC contaminated environment. The infantry could not pop their heads out of the hatch and fire or dismount for extended periods, so the idea was that they would contribute to the firefight as the vehicle carried them onto the objective. It also came out of experience in Vietnam where mounted infantry had become somewhat "gun shy" (with good reason) preferring to fight from within the protective armour of the APC.
All this led to the development of the IFV concept. The Soviets were the first, with the BMP-1, followed closely by the Swiss/Germans with the Tornado/Marder. The US attempted initially to use modified M113s but they were deemed unsuccessful. FMC developed the more advanced version of the M113, the AIFV, which was a modified M113 with a new hull, with sloping sides with firing ports in them and a 20mm turret:
The passengers sat in the centre, facing outwards, rather than along the sides, as in the traditional M113 (and which made the firing ports easier to use).
But the US Army passed on it, preferring to develop a more advanced vehicle in the M2 Bradley. It was adopted by several other nations though - Belgium, Netherlands, Turkey, Egypt, Malaysia, etc.
Most vehicles that were developed with firing ports have had them eliminated in favour of increased armour. The ports were a weak point, something the RN discovered in their warships in the First World War and most combatants in their tanks in WWII.