The reason was literally to make the phones thinner. The 3.5 mm jack was the thickest component by far, and it has to sit under the screen.
https://m.gsmarena.com/compare.php3?idPhone1=12773&idPhone2=...
This is the datasheet of a generic 3.5mm It is thinner than that: 3.2mm.