History homework helper
Jelly, &nbsp;17&nbsp;  16 bytes

DUµn/TṪṁ@Ṫ,j”-FṚ


A full program taking a list of years from, to and printing the result.

Try it online! or see the test suite.

How?

DUµn/TṪṁ@Ṫ,j”-FṚ - Main link: list of years [from, to]    e.g [1833,1871]
D                - convert to decimals                        [[1,8,3,3],[1,8,7,1]]
 U               - upend (to cater for differing lengths)     [[3,3,8,1],[1,7,8,1]]
  µ              - monadic chain separation, call that V
    /            - reduce V with:
   n             -   not equal?                               [1,1,0,0]
     T           - truthy indices                             [1, 2]
      Ṫ          - tail                                       2
         Ṫ       - tail V (pop from &amp; modify V)               [1,7,8,1]
       ṁ@        - mould (swap @rguments) V like that length  [1,7]
          ,      - pair that with (the modified) V            [[1,7],[[3,3,8,1]]
            ”-   - literal '-' character
           j     - join                                       [1,7,'-',[3,3,8,1]]
              F  - flatten                                    [1,7,'-',3,3,8,1]
               Ṛ - reverse                                    [1,8,3,3,'-',7,1]
                 - implicit print                             1833-71