Can someone tell me what these two lines of Arduino code do?
The program sends 3 bytes to a serial peripheral:

1) What appears to be a forward or reverse "command" or mode.

2) the lower 5 bits of the speed value

3) some more significant bits of the speed value (likely 7 more given the stated range)

That split between the 2nd and 3rd bytes is being done a bit unusually - typically you'd send the entire lower 8 bits, and then however many bits are leftover in the next byte.  It's possible it's done this way because the peripheral reserves the upper bit(s) of each byte for designating commands or framing, and so they aren't allowed to be used for data (at least, that's a scheme I've used on projects before).