I read that the function of data link and physical layer is to transmit data through the network....
Actually, all layers have the function of transmitting data. But they also have another important function that makes it more clear why they're separated: interpreting the data and taking the correct actions based on that.
The following overview concentrates on brevity and simplicity; don't rely on it for exact details.
The layers below the transport layer (layer 4 in OSI, TCP in the TCP/IP suite) handle sending data without reliable or in-order delivery. They generally vary between each other in how they handle addresses, e.g. IPv4 will have the actual end host as its destination address but Ethernet will have an intermediate router as its destination address.
The transport layer is probably what you're talking about when you talk about "transmit[ting] data"; that's the layer, when you give it some bytes, will get them to the other end in the order you sent them without losing any of them. But once the bytes arrive at the other end, the receiver needs to know what to do with them. Save them to a file? Forward them as an email? Return a web page?
That's where the application-level protocols come in: they determine how you format information between the two ends to get the job done that you want done. As Richard Huxton mentioned above, there will be various sequences of bytes that indicate a user wants to log in with a given name and password, that a directory listing is requested, that the following data should be written to a file with a given name, and so on.