Higher the number, newer the groupset, i.e. M751 = 1998, M785 = 2012
4 digit number are for road groupsets, M=3 digit = MTB, MX+2 digit = BMX, T+3 digit = Trekking; also expect some crossover with parts
For MTB, within that, first number indicates level, M6** = SLX/Zee M7** = XT, M9** = XTR etc
That’s it in really simple terms, google Shimano date codes, and there is plenty of info out there, especially for the older parts; just because a part is listed as a model year, it will probably have been available earlier than that, 2013 parts are in the shops now for some groupsets.