After you setup your iPhone, it has many background tasks to run including indexing, which is creating and sorting a searchable database of your data. Indexing is best performed when the iPhone is on the charger, so it can work extra hard during that.
It's also normal for your iPhone to exert heat when charging. If your iPhone were overheating at a dangerous level, it would display a Charging on Hold message and pause charging until it cooled down. You may also see that your iPhone may pause charging at 80% to cool down before it continues to 100%, as heat is not good for battery health longevity.