In Operating Systems, I can't understand why deadlock happens, why does a process not let go of a resource when it is done using it?
To answer part of your question: Processes are not smart. Processes just execute the code of their program, so if the program of P1 has not been written to release R1 when it's done with it, it won't be released.
Besides, the classical setting in which a deadlock happens does not have to do with processes not releasing resources after they are done with them, but rather with competing processes trying to acquire the needed resources.
Process A needs both R1 and R2 to perform some task, so it starts acquiring them. It acquires R1, and tries to acquire R2.
Just before P1 gets to acquire R1, some process P2 that also needs both R1 and R2 tries to acquire them. This time P2 starts with acquiring R2, and succeeds.
At this point the following two things happen:

P1 tries to acquire R2 which is unavailable, so it waits for R2 be released.
P2 tries to acquire R1 which is unavailable, so it waits for R1 be released.

From this point on both P1 and P2 are stuck waiting for another resource that will never be released, i.e., they are in a deadlock.
Notice that no process ever held a lock on a resource that didn't intend to use.
The problem was that P1 and P2 tried to lock the resources in a different order.
Finally, you might think that when P1 tries to acquire R2, and finds that it is unavailable it could just temporarily release R1 and try to acquire both R1 and R2 at a later time.
However, without additional synchronization, this also doesn't ensure that P1 and P2 will manage to acquire the needed resources. The following could happen:

P1 acquires R1, P2 acquires R2.
P1 tries to acquire R2, and finds that R2 is unavailable.
P2 tries to acquire R1, and finds that R1 is unavailable.
P1 releases R1.
P2 releases R2.
P1 acquires R1 and is about to acquire R2.
P2 acquires R2 and is about to acquire R1.
P1 tries to acquire R2, and finds that R2 is unavailable.
P2 tries to acquire R1, and finds that R1 is unavailable.
....