If the price is the same or close, always book with the operating carrier. In case of IRROPS, you will be in a much better position to reschedule flights if you booked via LH. Booking an LH flight via UA means that you will be at the mercy of whatever seats LH makes available to UA, and the flights you may want to get on may not be open to the agent from UA who will be rebooking your flight. Also, online seat selection on LH-group flights is a bit of a mess, and there is a very good chance you will NOT be able to select/change seats on the LH website/app if you book via UA (you will definitely not be able to select LH seats on the UA website). The miles earned are based on the airline you are flying on and the fare bucket of the ticket, so booking the same fare code will earn the same miles, regardless of where you book the flight. You will also not be eligible to bid for an upgrade on LH if you booked via UA.