A sub program, whether its associated with CNC G code programs, or with software coding, is mostly used for reusable or repeatable code.
Lets say a pocket that uses 500 blocks to machine is repeated 10 times on a workpiece. You can either have a main program that has 5000 blocks plus a hand full of blocks to start and end the program, or you can have a main program that has the same hand full of blocks to start and end, plus 10 call blocks to the sub program and the sub program. Another example is if a large number of holes are being spot drilled, pilot drilled, drilled to a larger diameter, and then reamed. You could duplicate the X Y coordinated of the holes in the main program for each of the tools, or you could put the X Y coordinates in a Sub program and call it from the main program for each of the tools.
The structure of sub programs varies with the control, but the basic logic is the same. With a Fanuc controls, the sub programs are loaded as separate programs and called initially from the main program and then can call other sub programs or return to the main program. Hass controls have the subs loaded at the end of the main program, but are called from the main program and can call other subs.
Its neither easier nor harder to learn G and M codes using Sub programs, but it makes for more compact, structured programs, and usually more easy to follow, particularly if there is a lot of code involved. Sub programs also prove useful when proving a program. If for example the sub is to machine a number of identical pockets in the workpiece, once the detail has been proved correct for the first pocket, the detail will be correct for all subsequent pockets, only the position of each pocket will have to be checked on prove out.