This is tricky question because 95% people will answer because total length of ip datagram is 16 bit so 2^16-1, well that's the correct answer but it's not the correct reason.
The actual reason is behind the switching logic so, there are two kind of generally switching is used, i.e., circuit switching and packet switching. From which in practicality packet switching is generally implemented because of it's pipelining functionallity so it's notice that when packet size is 16 bits then the total transmission time of packet is came to be minimum by which the total size of packets are 16 bits which is responsible for 2^16-1 or 65535 B.