What is the main purpose of Portgas D. Ace's death? I want to know what turn of events did it take by the death of Portgas D. Ace in One Piece. I don't seem to understand.
Out of universe reason: the capture and death of Ace seems to setup the War of the Best and ensure that Luffy unequivocally lost it. This moment of loss is like "The Ordeal" in "The Hero's Journey".  Think the Empire Strikes Back for Luke.  By having the main character lose and recover, it deepens the character and makes what comes next more meaningful. 

This arc is analogous to the Loguetown arc.  Both arcs are the last ones in their particular sea before the short arc to enter the new one, reintroduce characters from earlier in that sea, and introduces some characters who will be important in the future. More importantly, they show some characters who are so overpowered compared to Luffy it is hard to see how he will beat them and has Luffy lose that fight. This shows Luffy needs to get stronger in the next sea quickly or he will die.

In Loguetown, Luffy is the one on the exection platform. He has to be saved by his daddy, loses a fight to an enemy he can't lay a finger on, and runs away. He even needed help to run away.  This teaches the audience that the Grand Line will be far harder than the East Blue.

In the War of the Best, it is worse.  Luffy plays the role of the lightning bolt to release Ace from the Execution platform but is proven to be no where near strong enough to protect Ace. Even to get that far Luffy needed the help of strangers. This clearly shows the audience what the new World will be like.  It also motivates Luffy to get stronger...once he recovers his composure.