We mainly use to allocate memory dynamically while execution of program.if you are familiar with linked list then you know that fact that we prefer linked list instead of array when we don't know size of data. its because in case of array we fixed the size but in case of linked list, we just use malloc() function and allocate memory whenever we require to store a value,address etc.
See an example:
struct node *next;
// I am going to allocate memory dynamically using malloc()
// allotted memory as we are going to store a value inside newnode
// as we connect nodes backward or forward and continue this process