Why the SDA line has to transfer NACK after receiving data from i2c device?

If the transmission fail,dose the slave transmit ACK?

Why do not transmit ACK as master writing data to the slave device successfully?

Why do you want to know ? What do you mean with the transmission failed ? What would fail ? Sending a NAK is the same as doing nothing. The pullup resistor will keep the SDA high when nothing is active, and that is the same as a NAK.

You can check the return values, as I told you here : http://forum.arduino.cc/index.php?topic=392140.msg2801247#msg2801247

The Slave does a ACK when it sees its address. After that it depends if the Master is reading data or sending data. I think that the Slave does a ACK when the Master is writing data, and the Master does a ACK when it is receiving data. The I2C bus is not a perfect communication protocol. Some things are good, some thing might seem not so good, but something else would probably have major disadvantages.

The ATmega328P has good hardware for I2C inside the chip. The ATmega328P is for example used in the Arduino Uno. So the I2C protocol is good, the I2C hardware inside the ATmega328P is good, but the Arduino Wire library could be better, it is blocking, it waits until a transaction has finished, the buffer size limits the amount of data, the returning errors are not handled consistant, and so on.

Do you have a logic analyzer ? Some logic analyzers show the I2C protocol : https://www.saleae.com/