Question: why udp is needed in transport layer?
Answer: UDP is used at the transport layer because it is a transport layer protocol. It provides "provides end-to-end communication services for applications" (RFC1122). Reliability services are optional for transport layer protocols.