What the films show, what the filmmakers said, and what is only a fan reading.
Tony Stark dies saving everyone at the end of Avengers: Endgame. Looking back, his films keep putting his life on the line. Here's what is on screen, what the writers and directors said about his ending, and why 'it was planned since 2008' isn't backed up.
Levels marked "Sourced facts" are checked against the sources listed at the bottom. Levels marked "Fan theory" are interpretation, not confirmed by the films or their makers.
Iron Man (2008): shrapnel near his heart leaves Tony relying on an electromagnet, then the arc reactor he and Yinsen build in the cave; once free, he stops Stark Industries making weapons. Iron Man 2 (2010): the palladium core keeping him alive is slowly poisoning him, until he makes a new element from a diagram his father hid. The Avengers (2012): he guides a nuclear missile through the wormhole in what looks like a sacrifice of his own life, and the Hulk catches him as he falls. Iron Man 3 (2013): he has PTSD and panic attacks after New York. Avengers: Endgame (2019): he works out time travel and, in the final battle, uses the Stones to wipe out Thanos and his army, which kills him.
According to Wikipedia's Endgame article, which cites interviews: the writers, Christopher Markus and Stephen McFeely, saw Tony's death as a move to selflessness that closed the chapter he began, and felt he had earned it after getting the retirement he wanted (marriage to Pepper and a daughter). Joe Russo said Tony always knew he would die because he could never stop trying to protect the universe. The same article says the Russo brothers built Tony's final arc starting from Captain America: Civil War (2016) and got Robert Downey Jr.'s approval for it.
This part is fan reading. Some fans argue Tony's death was mapped out from his very first film. We could not find any statement from Marvel saying that, and the Russo brothers only joined the series with The Winter Soldier (2014). What can be said is that the films keep returning to Tony risking himself, and that the people who wrote and directed Endgame chose to pay that off. Reading earlier films as 'clues' is hindsight, which can be fun, but it isn't evidence of a plan.