This is because the data gram has to travel to different networks and those different network may have different Maximum Transmissible Unit (MTU). The source (sender) can only know about the MTU of the current network and Network Layer at the source can fragment accordingly. But when the packet travels in the inter-networks, the MTU might be different. Since routers are the one responsible for connecting networks, so they are the best ones to do the fragmentation, when needed.